Reputation: 427
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
Upvotes: 5
Views: 5526
Reputation: 1878
Dialog provides two properties you might want to check: isLoaded
and open
. By digging the code you'll find the following descriptions:
So, you could just:
var dialog = dijit.byId("blah");
if( dialog.open ) {
dialog.destroy();
}
Upvotes: 4
Reputation: 37277
Do you want to hide it or destroy it?
If you just want to show/hide it you can do the following:
var dialog = dijit.byId('blah');
if (dialog) {
if (dialog.open) {
dialog.hide();
}
else {
dialog.show();
}
}
If you wanted to destory it to free up memory:
var dialog = dijit.byId('blah');
dialog.destory();
I think destroy
is recursive since it calls its parent destroy
method and one of its parents is dijit.layout.ContentPane
.
Upvotes: 1