Opened 14 years ago
Last modified 14 years ago
#7959 closed defect
Removing a tree and re-adding it to a ContentPane fails in 1.2.0 — at Initial Version
Reported by: | spidey2099 | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | tbd |
Component: | Dijit | Version: | 1.2.0 |
Keywords: | tree, contentpane, readding fails | Cc: | |
Blocked By: | Blocking: |
Description
In my code, I am creating a tree and when something changes in a critical section of my application, I am removing the old tree and adding a new one. The tree is attached to a ContentPane? or an ExpandoPane?. Well the ContenPane?.destroyDescendants() function in 1.2-0b1 was a direct call to it's parent - dijit._Widget.js - which does this: <code>
destroyDescendants: function(/*Boolean?*/ preserveDom){
summary: Recursively destroy the children of this widget
and their
descendants. preserveDom: If true, the preserveDom attribute is passed to
all descendant
widget's .destroy() method. Not for use with _Te
mplated
widgets.
TODO: should I destroy in the reverse order, to go bottom up? dojo.forEach(this.getDescendants(), function(widget){
if(widget.destroy){
widget.destroy(preserveDom);
}
});
</code>
However in 1.2.0 and later, the ContentPane? does have a destroyDescendants() function which does this: <code>
destroyDescendants: function(){
summary: Destroy all the widgets inside the ContentPane? a
nd empty containerNode
Make sure we call onUnload TODO: this shouldn't be called when we are simply destroying
a "Loading..." message
this._onUnloadHandler();
dojo.html._ContentSetter keeps track of child widgets, so we
should use it to
destroy them. Only exception is when those child widgets were specified in
original page markup
and created by the parser (in which case _ContentSetter doesn
't know what the widgets
are). Then we need to call Widget.destroyDescendants(). Note that calling Widget.destroyDescendants() has various iss
ues (#6954),
namely that popup widgets aren't destroyed (#2056, #4980) and the widgets in templates are destroyed twice (#7706) var setter = this._contentSetter; if(setter){
calling empty destroys all child widgets as well as e
mptying the containerNode
setter.empty();
}else{
this.inherited(arguments); dojo.html._emptyNode(this.containerNode);
}
},
With this new change, if I remove and re-add a tree to a ContentPane?, it fails to render.
</code>