tags:

views:

35

answers:

2

Hello,

I am using a JQuery dialog field. If it is open, I want to do one thing. If it is closed, I want to do another. My question is, how do I detect if a JQuery dialog box is open or not?

Thank you,

+1  A: 

If you want to check if the dialog's open on a particular element you can do this:

if($("#elem").closest('.ui-dialog').is(':visible')) { 
  //do something
}

Or if you just want to check if the element itself is visible you can do:

if($("#elem").is(':visible')) { 
  //do something
}

Or...

if($("#elem:visible").length) { 
  //do something
}
Nick Craver
+2  A: 

You read the docs.

$("#mydialog").dialog( "isOpen" )

Byron Whitlock
Doh! I don't know how i overlooked that. Thank you.