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);     }); }); 

jsfiddle - docs get_json


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -