Reputation: 826
When I create a new dijit/dojox widget, lets say a Button, doing:
new Button({...}, "domId");
And suppose I add my new button to a tab panel, at some point the user close that tab. It is my responsibility to destroy the button?
What about the dojox's widgets?
What about components like dialogs? (In jquery UI u must destroy the widget and the dom used to create it).
Thanks for your help guys.
Upvotes: 0
Views: 886
Reputation: 8641
Any widget constructed will be placed in the dijit.registry and vanishes on unload.
If you have a widget that gets constructed more then once, say if youre doing a ContentPane ajax loading layout - then you should destroy any widgets created before unloading the contentpane. That is, widgets which have been placed under the DOM of the contentpane.. If for instance you have a sidebar-menu, dont destroy and recreate it every time :)
If you use any extension of the ContentPane and it has dojo markup set as its contents - the parser takes care of registering and unloading the widgets automatically.
So to answer; not really.. You should not however, destroy a DOMNode which is the 'implementation' of a widget, nor remove any of the inner children of one. Instead call dijit.byId('widgetId')
to pull out the widget from registry - and then widget.destroy();
If its a dojox or a dialog or something else, its all the same. They are extended by dijit._Widget
and has the same base api - at least like, 90% of the dojox modules does.
Upvotes: 2