开发者

When to hide() a dijit.Dialog versus .destroyRecursive() in dojo

I have seen both used in code but I was wondering what is the preferred 开发者_运维知识库and more efficient method of closing dialogs using dlg.hide() or dlg.destroyRecursive()?


That depends on whether you're going to reuse the dialog or not. If it's cheaper to just re-create it (you define what's cheaper), use destroyRecursive(). Otherwise, create once and just hide() it any time you need to close it.

Keep in mind dijit will keep all the widgets you create in a registry. So simply letting the dialog variable go out of scope will not make it garbage collectable, and that opens up the possibility of a memory leak.


I find that I cannot completely destroy the widgets inside the dialog if I just call dialog.destroyRecursive() though the dialog seems get destroyed.

Instead, I have to call dialog.hide() and then call this.destroyRecursive() in the onHide method.

However, this causes another unharmful error "exception in animation handler for: onEnd". But it does have all widgets in dialog get destroyed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜