Wednesday, 15 May 2013

javascript - How to prevent selecting of children once it's parent is selected? -



javascript - How to prevent selecting of children once it's parent is selected? -

i want disable children nodes automatically when parent node selected. how accomplish in jstree?

.on('select_node.jstree', function(e, data) { console.log("$$$$$$$$$"); obj = data.instance.get_node(data.node.id, true); if (obj.parentsuntil('.jstree','li').children('a.jstree-clicked').length || obj.children('ul').find('a.jstree-clicked:eq(0)').length){ data.instance.deselect_node(obj); } });

i used code couldn't find result. please help me out it.

you can utilize data.node.children children of node. or can utilize data.node.children_d children, children of children.

here illustration how iterate through children:

for (var = 0; < data.node.children_d.length; i++) { //for illustration disable node $(\'#jstree_demo_div\').jstree(true).disable_node(data.node.children_d[i]); }

hope helps!

javascript jstree

No comments:

Post a Comment