What's the correct way to destroy widgets inside TabContainer in Dojo/Dijit?
For each tab I'm loading new BorderContainer that includes basically a widget that includes any small widgets. But now that I'm trying to get it to work with tab control so that it destroys the previous page before loading a new one, I'm stuck. Right now I use a global variable to store active widget name and when user clicks a new tab, it fetches active widget's id from global variable and destroys it and then proceeds into loading the new active widget. This works but when I have destroyed the widget once, I can't get it to appear again. I get this error:
Uncaught Error: Tried to register widget with id==widget_foo_container but that id is already registered".
I'm using widget_XXX_container id for all the widgets so XXX is replaced by id of the widget.
I'm currently using dijit.byId('widget_foo_container').destroy() but it doesn't seem to do the job. I have also tried destroyDecendant() and destroyRecursive() but they don't produce wanted effect also. It seems that I might be missing a piece that actually finishes destroying the widget instead of just removing it from DOM.
destroyRecursiveshould be enough - it callsdestroyDescendantsanddestroyitself. For that matter, I'm curious why simply callingdestroyRecursiveon the BorderContainer itself didn't suffice in your case... - Ken Franqueiro