Remove nodes without children.

52 views
Skip to first unread message

Алексей Курдюков

unread,
Jul 18, 2014, 7:27:22 AM7/18/14
to fanc...@googlegroups.com
Hello,
I need to remove nodes and move all children to it's place.
I use code:
ref = $('#tree').fancytree("getTree"),
searchIDs
= ref.getSelectedNodes();

searchIDs
.forEach(function(node){
 $children
= node.children;
 if ($children!==null)node.parent.addChildren($children,node.getNextSibling());
 node.remove();
});

Where #tree is div with ul\li; If Nodes > 1 I have error "Uncaught TypeError: Cannot call method 'addChildren' of null ".
Could you say any solution?

Reply all
Reply to author
Forward
0 new messages