| Issue 453: | DynaTreeNode.remove throws an exception if the node isn't rendered | |
| 1 person starred this issue and may be notified of changes. | Back to list |
To reproduce: 1. Collapse a parent node 2. Call 'remove' for any child node and insert the same node again 3. Repeat step 2 'remove' method throws an error. In Chrome the error is: Error: An attempt was made to reference a Node in a context where it does not exist. at Object.DynaTreeNode.removeChild (http://dynatree.googlecode.com/svn/trunk/src/jquery.dynatree.js:1471:12) In other browsers the error can be different. jsFiddle: http://jsfiddle.net/tNcEJ/11/ Problem code - removeChild method, line 1437: if(this.ul){ // $("li", $(this.ul)).remove(); // issue 399 this.ul.removeChild(tn.li); // issue 402 } Replace with: if(this.ul && tn.li){ this.ul.removeChild(tn.li); // issue 402 } I suppose you need to do the same thing in removeChildren method to fix issue 231 . At least move $("li", $(this.ul)).remove() out of the 'for' cycle, no need to remove all li nodes at each iteration. Dynatree version: 1.2.4
Sep 7, 2013
This issue was updated by revision r677.
Sep 7, 2013
could you please verify?
Status:
Waiting
Sep 25, 2013
Works great, thanks! Please excuse me for a long delay. What about the same fix in removeChildren method?
Oct 3, 2013
(No comment was entered for this change.)
Status:
Accepted
|
Labels: Milestone-Release1.2.5