Get the immediate parent of child node in jstree

I want to retrieve the parent of the child node without clicking on the tree..


Above command give me the immediate parent when we click on the child nodes.

Is there a way to get the parent node without clicking on the child node.

Regards, Praque M



It seems the "data.inst" was renamed in newer versions to "data.instance". This made tracking down the solution difficult

data.instance.get_parent(data.node) returns the string ID of the parent (much unexpected for me). To get the parent I had to call data.instance.get_node() on the string ID.

data.instance.get_parent(data.node) is also accessible thru data.node.parent.


$('#MaterialCollectionTree').on('activate_node.jstree', function(e, data) {
  if(data.instance.is_leaf(data.node)) {
    alert("Leaf: " + data.node.text);
    alert("Parent: " +  data.instance.get_node(data.node.parent).text);

It is a bit more complex then that

parent_node = $.jstree._reference('#tree_id')._get_parent(n);

The variable parent_node is a jquery object so the command


is the same as



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.