jquery - JSTree check is selected nodes are leaf or make only leaves selectable -
i created jstree follows
$('#js-tree').jstree({ 'core' : { 'data' : { 'url' : "${pagecontext.request.contextpath}/maketree", "plugins" : [ "types", "search"], 'data' : function (node) { return { 'id' : node.id }; } } } });
i want check if selected node leaf node while submitting information -
var selectedleaves = $("#js-tree").jstree("get_selected");
but gives me array of id's only. how either use is_leaf method filter our leaf nodes selected nodes? referred post - force user select leaf nodes solution did not work me.
i found solution on own using argument get_selected
api filter out leaves folders -
var nodes = $("#js-tree").jstree(true).get_selected("full", true); $.each(nodes,function(i, node){ if(node.children.length >0){ console.log("not leaf"); } else{ console.log("leaf"); } });
if have better solution please let me know.
Comments
Post a Comment