How to get node by ID in Jstree

Try this:

var node = $('#dashboardTree').jstree(true).get_node('1, true')

New addition: true

OR

Change this:

var node = $('#dashboardTree').jstree(true).get_node('//something')

To this:

var node = $('#dashboardTree').jstree(true).find('//something');

Get the JSON of the parent and find the children.

Read the documentation on jstree/JSON.


To get the node use this:
$('#dashboardTree').jstree(true).get_node('1');

If you need the actual DOM node, use this: $('#dashboardTree').jstree(true).get_node('1', true);

But only invoke this once the tree is ready:

$('#dashboardTree').on('ready.jstree', function (e, data) {
  var node = data.instance.get_node('1');
})
initDashboardArchiveTree(); //Initial tree

Tags:

Jquery

Jstree