Daft
Daft

Reputation: 10964

Close whichever jQuery Mobile dialog is open. jQuery Mobile / jQuery

I have two jQuery Mobile dialogs containing forms. I want them to both call the same function when they close. Only one will be open at a time. So I need the function to tell which is open and to target that one.

The function closes the dialog and refreshes the page.

Right now I have it working but only for one dialog.

        function backToPage(){
            //jQuery('#save-contact-dialog').dialog('close');   
            $('#edit-contact-dialog').dialog('close');
            location.reload();
        };

So maybe

        function backToPage(){
            if($('#save-contact-dialog').dialog() == open{
                   $('#save-contact-dialog').dialog('close');
                   location.reload();
             }else  
                   $('#edit-contact-dialog').dialog('close');
                   location.reload();
        };

Obviously this is jibberish but if someone could help with a non-jibberish answer, I would be very happy!

Cheers

Upvotes: 0

Views: 56

Answers (1)

Reinstate Monica Cellio
Reinstate Monica Cellio

Reputation: 26143

Try this...

$(".ui-dialog:visible").dialog("close");

It should close any visible dialogs.

Upvotes: 1

Related Questions