When to hide () dijit.Dialog vs .destroyRecursive () in dojo

I saw both used in the code, but I was wondering what is the preferred and effective method of closing dialogs using dlg.hide () or dlg.destroyRecursive ()?

+4
source share
2 answers

It depends on whether you intend to reuse the dialog or not. If itโ€™s cheaper to just recreate it (you determine which is cheaper), use destroyRecursive() . Otherwise, create it once and just hide() anytime you need to close it.

Keep in mind that dijit will save all widgets created in the registry. Thus, a simple rejection of the dialog variable goes beyond the scope, this will not be done by the garbage collector, and this opens the possibility of a memory leak.

+3
source

I find that I cannot completely destroy the widgets inside the dialog box if I just call dialog.destroyRecursive() , although the dialog seems to be destroyed.

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

However, this causes another harmless error " exception in animation handler for: onEnd ". But he has all the widgets in the dialog that will be destroyed.

+2
source

All Articles