, phusick, , . :
var dcHandles = [], dsHandles = [], dc = dojo.connect, ds = dojo.subscribe;
dojo.connect = function () {
var h = dc.apply ( dojo, arguments );
dcHandles.push ( h );
return h;
};
dojo.subscribe = function () {
var h = ds.apply ( dojo, arguments );
dsHandles.push ( h );
return h;
};
dojo.subscribe ( "unload", function () {
dojo.connect = dc;
dojo.subscribe = ds;
var w, mll;
mll = dojo._windowUnloaders;
while (mll.length) {
( mll.pop () ) ();
}
if ( dijit.registry ) {
w = dijit.byId ( "topLevelItem1" );
w && w.destroyRecursive ();
w = dijit.byId ( "topLevelItem2" );
w && w.destroyRecursive ();
dijit.registry.forEach ( function ( w ) {
try
{
w.destroyRecursive ();
}
catch ( ex )
{
$.error ( ex );
}
} );
}
dojo.forEach ( dcHandles, function ( h ) {
dojo.disconnect ( h );
} );
dojo.forEach ( dsHandles, function ( h ) {
dojo.unsubscribe ( h );
} );
my.global.values.value1 = null;
dcHandles = [];
dsHandles = [];
} );
The above gave me some confidence that everything becomes unregistered / destroyed / de-link without changing a lot of code.
source
share