Login Register

destroy

Widget not destroyed when parent dialog closes?

Hi all,
I have written a widget using a timer to trigger some XHR action which works fine. But when I place this widget within a dialog (to be more precise: in a TabContainer within a Dialog) and the user "closes" the dialog by hitting the "x"-Button before the timer fires I want to clear the timer to reduce server load because the data which gets requested during the onTimer event is never showed to the user if the Dialog is no longer visible.

I had expected that the destroy() method would be called but that seems not to be the case in Dialog's hide() method.

General dijit cleanup question

Hail to the mighty dojo/dijit devs ;)

Suppose you have a page with a number of dijit widgets created either programmatically or by the parser. Do i need to cleanup/destroy anything on page unload or will it be done automagically by dijit/dojo?

I'm asking because I'm not quite sure how to handle the cleanup of my custom widgets (which are derived from dijit classes). They are in the dijit registry but (if there *is* a cleanup mechanism) will they all be properly destroyed, e.g. destroy() called for each of them? Or do I have to call it in the onunload hook-up?

Thx for some insight.

Bug in _Widget.destroy() or wrong usage?

Hi,

when I call _Widget.destroy on my Widget I get an error. Telling me that dojo.disconnect() is expecting an array.
Wich I think is right because it expects a handle and a handle is an array.

In the destroy function disconnect is called like this:

dojo.forEach(this._connects, function(array){
                        dojo.forEach(array, dojo.disconnect);
                });

As I see it, there is one forEach too much. Disconnect() is called with the elements of the handle array.

Or am I missing something. So strange that nobody discovered this earlier.

FYI -- How to cleanly destroy a dijit.Menu in Dojo 1.0.x

In case any others out there are being plagued by the dijit.Menu bug where it won't cleanly destroy itself -- this is a work around until they get it fixed.

Do the following after a menu closes (by attaching to "onClose" event of the menu)

dijit.byId( '/*id of menu*/' ).destroy(); //removes dijit registry entry for menu itself

//finds the orphaned menus on the body dom node and deletes the widgets.
dojo.forEach( dojo.query( ".dijitMenuTable" ).map(dijit.byNode), function( widget ){ widget.destroy(); } );

delete command

I tried to run the following code:

var x = 10;
delete x;
alert ("x is "+x);

and got "x is 3". my questions are: why delete seems to not work? when are you expected to use it? is there a URL where I can find explanation about destructors in general?
Thanks!!

Syndicate content