Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell if a jquery ui dialog query has been initialized?

I have the following code to detect if a jquery ui dialog is open:

if ($("#dialog-myDialog").dialog("isOpen")) {
      return;
}

which works fine but I found a situation where this code get called prior to the dialog being initialized in the first place and this if statement seems to just blow up in this case.

What is the best way to check if a jquery ui dialog has been initialized so I can properly handle this situation.

like image 951
leora Avatar asked Apr 09 '15 02:04

leora


1 Answers

Test whether the element has the ui-dialog-content class:

if ($("#dialog-myDialog").hasClass("ui-dialog-content") &&
    $("#dialog-myDialog").dialog("isOpen")) {
    return;
}
like image 62
Barmar Avatar answered Oct 01 '22 07:10

Barmar