David Hayes David Hayes - 1 year ago 118
jQuery Question

How do I programmatically select a node in jsTree and open all parents

In a multi-level jsTree how do I select a particular node (probably a leaf node) and expand all it's parents?

From this JSFiddle (http://jsfiddle.net/mmeah/fyDE6/) I want to programmatically select Grand Child and have all parent nodes opened.

For some context I'm trying to ensure the user returns to the correct node in the tree if they follow a deep link into my site

Answer Source

Ah ha, I was on the right track but I had a race condition between my deep linking parsing code and the construction of the tree

To select a node and trigger the event

$("#tree").jstree("select_node", selector).trigger("select_node.jstree");

To do this after the tree has loaded so it works...

$("#tree").jstree(...).bind("loaded.jstree", function () 
    $("#tree").jstree("select_node", selector).trigger("select_node.jstree");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download