I have a jstree. I want to select the node which is bound to the object which has a location with id of 158. This works but seems stupid. What\'s the more idiomatic way of doing
If you're populating the tree using HTML instead of JSON data and wondering how to set the node_id
, you just need to set the id attribute of the element!
Then
$('.tree-menu')
.jstree(true)
.select_node("node_3");
will select the Node 3 - Level 2
node.
For those getting javascript errors, remember to use Full version of jQuery
, not the slim version!
For all down voters, here is the demo to prove it's working: https://jsfiddle.net/davidliang2008/75v3fLbs/7/