jquery - Jstree Open specific branch on load -


i'm having trouble finding way open specific js tree branch on load. current tree loaded through ajax , shows top level, other branches loaded via ajax when expanded. want if user loads page @ place in tree want tree load branch open on tree.

i'm pretty sure can add json passing children part json specific node. how load tree branch open?

i can perform after load function open nodes specify these feels little messy, there way open branch on load?

my current function loads tree via json this:

$.jstree.defaults.core.data = true; $('.nav-tree').jstree({     'core' : {         'data' : {             'url' : function (node) {               return host+ "treenavigation?format=json";                                     },             'data' : function (node) {                 return node.id === '#' ? { 'rootid' : 0} : {'rootid' : node.id};             }         }     },     "plugins" : [         "wholerow"     ] }); 

jstree has event loaded.jstree load, in can add code open node using $(this).jstree("open_node", 'your node').

var = 2; $('.nav-tree').on('loaded.jstree', function(e, data) {     // invoked after jstree has loaded     $(this).jstree("open_node", $(nodes[i])); });  $('.nav-tree').jstree({     'core' : {         'data' : {             'url' : function (node) {               return host+ "treenavigation?format=json";                                     },             'data' : function (node) {                 return node.id === '#' ? { 'rootid' : 0} : {'rootid' : node.id};             }         }     },     "plugins" : [         "wholerow"     ] }); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -