Hi, I'm creating a visual tree structure in which every item can have multiple childs. In the following code the parent item adds one child to itself. But for some reason the child adds itself as a child of its own in an infinite loop:
----- CODE ------ var Item = Class.create({ column: null, text: null, childs: [], parent: null, initialize: function(column, text, parent) { this.column = column; this.text = text; this.parent = parent; }, addChild: function(child) { this.childs[this.childs.length] = child; } }); var startI = new Item(1, 'start', null); var vervolg1 = new Item(2, 'vervolg 1', startI); var vervolg2 = new Item(2, 'vervolg 2', startI); startI.addChild(vervolg1); startI.addChild(vervolg2); ----------------------------------------- You can find an image of the result (in the console) on http://www.bartblok.com/problem.PNG Why is this an infinite reference? The code should add vervolg1 and vervolg2 as childs of startI, but not childs of themselves. I hope someone can help me :) -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.