This patch adds functionality to destroy the dialog to cleanup memory. Index: dojo-release-1.3.2-src/dijit/Dialog.js =================================================================== --- dojo-release-1.3.2-src.orig/dijit/Dialog.js 2009-09-04 11:21:13.000000000 -0700 +++ dojo-release-1.3.2-src/dijit/Dialog.js 2009-09-04 11:22:00.000000000 -0700 @@ -120,6 +120,7 @@ this.connect(this, "onExecute", "hide"); this.connect(this, "onCancel", "hide"); this._modalconnects = []; + this._subscriptions = []; }, onLoad: function(){ @@ -165,7 +166,7 @@ this._moveable = (dojo.isIE == 6) ? new dojo.dnd.TimedMoveable(node, { handle: this.titleBar }) : // prevent overload, see #5285 new dojo.dnd.Moveable(node, { handle: this.titleBar, timeout: 0 }); - dojo.subscribe("/dnd/move/stop",this,"_endDrag"); + this._subscriptions.push(dojo.subscribe("/dnd/move/stop",this,"_endDrag")); }else{ dojo.addClass(node,"dijitDialogFixed"); } @@ -403,9 +404,22 @@ this._position(); } }, - + + // destroy and remove the DOM elements on close instead of just hiding + close: function() { + // wait for the fadeOut ends before destroy. invoking hide() cause fadeOut to play + this.connect(this._fadeOut, "onEnd", function() { + this.destroy(); + }); + this.refocus = false; + this.hide(); + }, + destroy: function(){ + delete this._fadeIn; + delete this._fadeOut; dojo.forEach(this._modalconnects, dojo.disconnect); + dojo.forEach(this._subscriptions, dojo.unsubscribe); if(this.refocus && this.open){ setTimeout(dojo.hitch(dijit,"focus",this._savedFocus), 25); }