nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jqTree / _entries / 23_oncanselectnode.md
1 ---
2 title: onCanSelectNode
3 name: options-oncanselectnode
4 ---
5
6 You can set a function to override if a node can be selected. The function gets a node as parameter, and must return true or false.
7
8 For this to work, the option 'selectable' must be 'true'.
9
10 {% highlight js %}
11 // Example: nodes with children cannot be selected
12 $('#tree1').tree({
13     data: data,
14     selectable: true
15     onCanSelectNode: function(node) {
16         if (node.children.length == 0) {
17             // Nodes without children can be selected
18             return true;
19         }
20         else {
21             // Nodes with children cannot be selected
22             return false;
23         }
24     }
25 });
26 {% endhighlight %}