I am using the jsTree jquery plugin
I am trying to fetch all the nodes and sub nodes of a selected parent. But somehow it's not working unless I use recursion. Is there a better way inherent to jsTree?
You can get full tree all by using this selector: $("#demo1").find("li > a")
I tried the previous solution and it is not working with the latest version of jsTree (v3.2.1). Below is an updated solution to get the child nodes and sub nodes of the parent.
$("#myTree").bind('selected_node.jstree', function (node, data) {
var selectedNodes = $("#myTree").jstree(true).get_json(data.node.id, { flat: true });
for (var i = 0; i < selectedNodes.length; i++) {
// Apply logic here
// ...
// ...
// ...
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With