开发者

Closing all jquery dialog windows in JavaScript

How does one close all jquery ui dialog windows in javascript?

Situation:

The page has multiple things that can be opened using the dialog boxes. I need a w开发者_Python百科ay to close all previous windows before opening a new one.


They all have the .ui-dialog-content class, so select by that and close them, like this:

$(".ui-dialog-content").dialog("close");


Be careful with the above. If you define a close method for your dialog, it will get fired even if the dialog is not open. This was a huge issue in an Angular project where we were manually calling $apply() in our dialog close method. Another event was trying to close all dialogs on the screen and our close method was called even though wasn't open resulting in a digest issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜