How to check whether selected node is having child nodes or not in jstree?
I m taking selected node by following code.
var selected=$("#warehouseTree").jstree('get_selected');
and now i want to check for child nodes for sel开发者_StackOverflow中文版ected node.
This is simply how you extract children information from a specific node.
$("#tree_2").jstree().get_node("13").children
Try this:
var tree = jQuery.jstree._reference('#warehouseTree');
var children = tree._get_children(selected);
Which will return an array of jQuery objects of the children of the selected node.
this will help.
if(selected.children().size() > 0)
{
//has child
}
This is how you can check whether a node has children or not.
var tree = jQuery.jstree._reference('#warehouseTree');
var isParent = instance.is_parent(selected);
console.log(isParent) // true for directory
精彩评论