I wrote a recursive function to uncheck all menu nodes. It works well, but I need to know if it is right to leave empty block inside if (nodes[i].children.length === 0)
base case.
Is there a better design choice?
The function:
function uncheck_all_tree (nodes) {
var i, n, n_dom_el;
for (i = 0; i < nodes.length; i++) {
if (nodes[i].children.length === 0) {
// recursion bottom;
} else {
uncheck_all_tree(nodes[i].children);
}
// pop nodes from recursion stack
n = tree.jstree('get_node', nodes[i]);
n_dom_el = document.getElementById(n.id + '_anchor');
if (n_dom_el !== null) {
console.log(n.id + '_anchor');
n_dom_el.className = 'jstree-anchor';
}
n.state.checked = false;
}
}