In my JStree, I want the user to be able to select only the leaves of the tree. For example: Nodes that have no children. My idea is to bind the select event and manually check if the selected node has children, and then select / not select node accordingly.
Is there an easier way? or is this the only obvious solution?
you can use
In the code.
$('#treeID') .bind('before.jstree', function(event, data){ switch(data.plugin){ case 'ui': if(data.inst.is_leaf(data.args[0])){ return false; } break; default: break; } })
2014 - version 3.0.1
$('#jstree').on('activate_node.jstree', function(e, data) { if(data.instance.is_leaf(data.node)) { ... } });
A simple solution to use the CheckBox plugin (for RadioButton behavior) here
$('#treeview').bind('activate_node.jstree', function (event, data) { if (data.instance.get_checked().length > 1) { data.instance.uncheck_all(); } });
In this jquery.
$('#jstree').on('activate_node.jstree', function(e, data) { if(!data.instance.is_leaf(data.node)) { data.instance.deselect_node(data.node, true); } }
This code deactivates node if node is not a leaf.
Thus, only leaves are selected.
Source: https://habr.com/ru/post/1386283/More articles:How to use environment variable in xcconfig #include? - includeJavascript: "Source code unavailable for this location" msg during debugging with IE - javascriptHow can I designate a word given to tokens that are not fully included in this word? - regexhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1386281/how-could-i-create-a-function-that-would-consolelog-details-every-time-jquery-binds-to-a-click-event&usg=ALkJrhiMrV8dZSvhMFjpHcrXJuBmdKiiggbrowser shows a progress bar as it moves, even when the page is loaded - javascriptAny tutorial on integrating SmartGWT and JasperReports? - javaAbout the same application, but different binary files for different application stores - app-storeHow can I make it difficult to trigger click events twice? - javascriptbrowser shows half the execution bar even after the page is fully processed - javascriptJSTree check selected by leaf nodes or only leaves leaves selectable - jqueryAll Articles