Hi am using jsTree and created the below shown Tree
Now i want to disable n th node if (n-1) th node is selected,ie user cant able to select different level of nodes.
eg:
Is it possible to achieve this requirement ????
Thanks in advance
You can use an attribute added by jsTree to all li
elements - the aria-level
attribute. It starts from 1 for root element and spans whole tree showing level for every node.
You will have to do this:
changed
event to disable visible nodes from next level and below and open_node
to update status of to-be disabled nodes previously hidden (non-existent in the DOM till this moment to be exact)conditionalselect
plugin to disallow node selection if node is disabledI kept the currently selected level in var currentlevel
. You should check that it is kept local. Also you can surely optimize the code so it wouldn't repeat enable/disable functionality.
Check demo - JS Fiddle