RailsSon RailsSon - 1 year ago 157
Javascript Question

jsTree Open a branch

I am using the JQuery plugin jsTree, http://www.jstree.com/
I am able to expand the whole tree with the following method:


and also a specific node:

$("#tree").jstree("open_node", $('#childNode'));

I am having difficulty opening a branch of the tree, open branch opens it fine but does not open its parent if it has one.

Has anyone successully done this with jsTree? Let me know if you need more info.



Answer Source

You could use the binding

$("#tree").bind("open_node.jstree", function (event, data) { 
  if((data.inst._get_parent(data.rslt.obj)).length) { 
    data.inst._get_parent(data.rslt.obj).open_node(this, false); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download