Jstree get all child nodes of root

jstreenodes

How do I get all the the child nodes in jsTree? I need to click on a parent in the tree and get all of its children in an array. Preferably looping through and assigning a new associative array…but that's for later.

Where data.inst.obj is any parent node with children..
I've tried this: children=data.inst.obj.find("li").. array of 0

all_children= data.inst._get_children(data.rslt.obj);
still the length of this array (all_children.length) is 0.

I'm missing something obvious here I'm sure…

Best Answer

The tree can be inspected through the DOM without having to use the event handler data.

Example of how to read the tree: http://jsfiddle.net/mmeah/YKqEQ/

    var myTreeContainer = $.jstree._reference(myTree).get_container();
    var allChildren=myTreeContainer.find("li");
Related Topic