Kayla
Kayla

Reputation: 319

jstree get all child nodes of root

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...

Upvotes: 4

Views: 9519

Answers (1)

MMeah
MMeah

Reputation: 1042

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");

Upvotes: 0

Related Questions