Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if any jquery dialog happens to be open? [duplicate]

Looking for a general case solution to determine if any jquery dialog (there are multiple) is currently open. Have tried:

$(".ui-dialog-content").dialog("isOpen") === true
$(".ui-dialog").dialog("isOpen") == true
$(document).dialog("isOpen") == true
$("*").dialog('isOpen') == true

without any success. I expected ".ui-dialog-content" to work, since I can apparently close any open dialog with that selector, but it does not.

like image 668
lamont Avatar asked Feb 03 '12 14:02

lamont


3 Answers

you can try

if($(".ui-dialog").is(":visible")){
//dialog is open
}
like image 73
Rafay Avatar answered Oct 22 '22 13:10

Rafay


jQuery UI dailog has a method isOpen which returns true if the dailog is open. Call it on the element which has opened the dialog box.

$('.ui-dialog-content').dialog("isOpen");

Refrence: http://jqueryui.com/demos/dialog/#method-isOpen

like image 45
ShankarSangoli Avatar answered Oct 22 '22 12:10

ShankarSangoli


According to the API documentation, you should use

$( ".selector" ).dialog( "isOpen" )

to determine whether the dialog is open or not. The function returns a boolean. For example,

if( $("selector").dialog("isOpen")===true ){
     /*do stuff when dialog is open*/
} else {
     /*do stuff when dialog is closed*/
};
like image 1
Touhid Alam Avatar answered Oct 22 '22 13:10

Touhid Alam