admin管理员组文章数量:1336613
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
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
Share
Improve this question
edited Nov 21, 2011 at 18:28
Jason Plank
2,3365 gold badges32 silver badges40 bronze badges
asked Jul 20, 2009 at 23:16
shawn deutchshawn deutch
4271 gold badge6 silver badges10 bronze badges
1
- This is the end function: function bufferAddress(xCoord, yCoord) { if (dijit.byId("selectLocationDlg") !== undefined) { dijit.byId("selectLocationDlg").destroyRecursive(); } // some other code here } – shawn deutch Commented Jul 21, 2009 at 18:03
2 Answers
Reset to default 4Dialog 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();
}
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
.
本文标签: javascriptHow can I check to see if a Dojo dialog is loadedStack Overflow
版权声明:本文标题:javascript - How can I check to see if a Dojo dialog is loaded? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742407004a2469026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论