Manuel Schmidt Manuel Schmidt - 1 year ago 206
jQuery Question

JSTree - How to force user tp only select leafs of the tree

Within my JStree i want the user to only be able to select leafs of the tree. E.g.: Nodes that have no childs. My idea is to bind the select event and manually check whether the selected node has childs and then select/not select the node accordingly.

Is there a simpler way? or is this obvious solution the only one?

Answer Source

You can use

  • Types plugin
  • .is_leaf() for checking if the selected node is a child- node (leaf) or not. Returning false in 'before'-Event will reject selecting the node. See the jsTree groups

In the code.

.bind('before.jstree', function(event, data){ 
                case 'ui': 
                                return false; 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download