Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#1444 closed defect (worksforme)

when destroying the children, the tree.children.length keep increasing

Reported by: [email protected] Owned by: ilia
Priority: high Milestone:
Component: Widgets Version: 0.3
Keywords: tree Cc:
Blocked By: Blocking:


I've created a tree widget that has new content as the user click on the server. the parent (always the same) will have 4 children always: Host, CPU, NIC, Partition. However, the grandchildren will always be different.

When I destroy the children, I assume that it has 4 children. However, when I debug this, the tree.children.length always increases by multiple of 4. Is this an expected behavior. I used DOJO 0.3.1. if I just use a fixed length (4), the tree children doesn't get destroy and I will get duplicate.

Here is the snippet of code:

.. pane = dojo.widget.byId("pane1"); tree = dojo.widget.manager.getWidgetsByType("Tree")[1]; dojo.debug("Number of children:"+tree.children.length); for(i=0;i<tree.children.length;i++) {


} .. .. inode = dojo.widget.createWidget("TreeNode?", {title: "Host"}); tree.addChild(inode); cnode = dojo.widget.createWidget("TreeNode?", {title: "Hostname:"}); inode.addChild(cnode); .. .. inode = dojo.widget.createWidget("TreeNode?", {title: "CPU"}); tree.addChild(inode); .. .. inode = dojo.widget.createWidget("TreeNode?", {title: "NIC"}); tree.addChild(inode); .. ..

Change History (4)

comment:1 Changed 15 years ago by dylan

Milestone: 0.5

comment:2 Changed 15 years ago by dylan

Resolution: worksforme
Status: newclosed

Johnny, try going through the index in reverse order... once you delete an item, the length of the array decreases... also, be sure you use var for i to keep in the local scope:

for(var i=tree.children.length-1;i>-1;i--)

comment:3 Changed 15 years ago by dylan

Milestone: 0.50.4

comment:4 Changed 14 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.