javascript - jstree jquery how to iterate through all nodes -
i'm trying iterate through every node within treeview in jstree. treeview 4 levels deep can't seem past 1st level. following jquery used iterate.
$("#mytree").bind('ready.jstree', function (event, data) { $('#mytree li').each(function () { // perform logic here } }); });
here jsfiddle illustrating point. please on how can iterate through every node in jstree.
this gets children of tree in flat array .each
loop.
$("#tree").bind('ready.jstree', function(event, data) { var $tree = $(this); $($tree.jstree().get_json($tree, { flat: true })) .each(function(index, value) { var node = $("#tree").jstree().get_node(this.id); var lvl = node.parents.length; var idx = index; console.log('node index = ' + idx + ' level = ' + lvl); }); });
Comments
Post a Comment