Thanks!
I'll try that once I'm back to this track again. Got sidetracked by
other parts of the project.
/Göran
Richard W wrote:
> Following on from Fontzter's response, something like this will help
> you determine if the user has clicked outside of a dialog:
>
> $(document).click(function(e){
> if (!$(e.target).parents().filter('.ui-dialog').length) {
> // close your dialog
> }
> });
>
>
>
>
> On Nov 24, 9:47 pm, Göran Törnquist <[email protected]> wrote:
>
>> I tried two ways of solving it.
>>
>> 1. Putting the following code within the _init() of the dialog. Yes, I'm
>> patching the dialog:
>> $(document).click(function(evt) {
>> console.log('closing the dialog')
>> if(self._isOpen) {
>> self.close();
>> }
>> });
>>
>> Since I'm bringing up the dialog with the click on a button, it
>> immediately after triggers the handler. Since it's by then already open,
>> then it will be immediately closed. The console.log confirms that behavior.
>>
>> 2. Putting the following code to create and open the dialog from a click
>> on a button.
>> $(function() {
>> $("#selectme").dialog({
>> bgiframe: true,
>> autoOpen: false,
>> height: 300
>> });
>>
>> $('#open-dialog').click(function(evt) {
>> $('#selectme').dialog('open');
>> $('document').click(function() {
>> console.log('got a document.click')
>> $('#selectme').close();
>> })
>> });
>>
>> });
>>
>> The second fails, in that no clicks are ever reaching the code in question.
>>
>> I really prefer the first version since that makes it possible to wrap
>> everything of the behavior within the plugin. But right now I'm open to
>> any suggestions.
>>
>> /G ran
>>
>>
>>
>> Fontzter wrote:
>>
>>> $(document).click(function(){ //close any open dialogs });
>>>
>>> On Nov 24, 4:12 pm, G ran T rnquist <[email protected]> wrote:
>>>
>>>> Thanks Fontzer, but no, I'm using a standard dialog which has content
>>>> that serves like a value picker for arbitrary data. Something along the
>>>> lines of the datepicker, but not _the_ datepicker.
>>>>
>>>> I need to figure out how to catch a click outside the dialog.
>>>>
>>>> /G ran
>>>>
>>>> Fontzter wrote:
>>>>
>>>>> Are you using the dialog method of the datepicker? This should be the
>>>>> default behavior.
>>>>>
>>>>> http://jqueryui.com/demos/datepicker/#method-dialog
>>>>>
>>>>> Dave
>>>>>
>>>>> On Nov 24, 3:53 pm, G ran T rnquist <[email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I have a dialog that serves as a data picker. Problem is that I'd like
>>>>>> it to behave like the datepicker does. When you click outside of the
>>>>>> datepicker, it closes the datepicker.
>>>>>>
>>>>>> How can I make a standard dialog work the same way?
>>>>>>
>>>>>> /G ran
>>>>>>
>>>>>> --
>>>>>> This message has been scanned for viruses and
>>>>>> dangerous content by MailScanner, and is
>>>>>> believed to be clean.
>>>>>>
>>>>> --
>>>>>
>>>>> You received this message because you are subscribed to the Google Groups
>>>>> "jQuery UI" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group
>>>>> athttp://groups.google.com/group/jquery-ui?hl=en.
>>>>>
>>>> --
>>>> This message has been scanned for viruses and
>>>> dangerous content by MailScanner, and is
>>>> believed to be clean.
>>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google Groups
>>> "jQuery UI" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group
>>> athttp://groups.google.com/group/jquery-ui?hl=en.
>>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "jQuery UI" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/jquery-ui?hl=en.
>
>
>
>
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en.