Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check to see if a Dojo dialog is loaded?

Tags:

I am running a function that needs to close a Dojo dialog if it is loaded. How do I check if a dojo dialog is running? Do I use pure JavaScript and check by id if it is undefined?

if (dijit.byId("blah") !== undefined) { 
     destroyRecursive dijit;
}

Or do I use a property of the dialog object like:

isFocusable method
isLoaded property
like image 667
shawn deutch Avatar asked Jul 20 '09 23:07

shawn deutch


1 Answers

Dialog provides two properties you might want to check: isLoaded and open. By digging the code you'll find the following descriptions:

  • open: True if Dialog is currently displayed on screen.
  • isLoaded: True if the ContentPane has data in it, either specified during initialization (via href or inline content), or set via attr('content', ...) / attr('href', ...) False if it doesn't have any content, or if ContentPane is still in the process of downloading href.

So, you could just:

var dialog = dijit.byId("blah");
if( dialog.open ) {
    dialog.destroy();
}
like image 97
Maine Avatar answered Oct 03 '22 06:10

Maine