How to close all jquery ui dialog before open a new dialog?
I want to close all jquery dialogs before open a new dialog.
I'm trying with following code.
$(".ui-dialog-content").dialog("close");
It works but it too close new dialog too.
please help me 开发者_Python百科anyone.
Try:
$(".ui-dialog-content").not(<selector for the dialog you don't want to close>).dialog("close");
Just ran into this myself. I solved it like this. .dialog
is a class that all the elements I made into dialogs share.
$(".ui-dialog:visible").find(".dialog").dialog("close");
Following on from Chris's solution, you can do the same without adding your own custom class with:
$(".ui-dialog:visible").find(".ui-dialog-content").dialog("close");
How are you opening the new Dialog? You must be opening each dialog using it's own code, e.g.
$('#dialog1').dialog();
$('#dialog2').dialog();
etc... in order to open each individually?
Just give them all a class name class="opened-dialogs"
then call $('.opened-dialogs').dialog("close");
before then opening the new one.
精彩评论