I have a jstree as shown below:
$('#FolderTree').jstree({
'core': {
'data': [
{
'text': 'Claim key',
'state': {
'opened': false,
'selected': false
},
'children': claimKeys
},
{
'text': 'Client',
'state': {
'opened': false,
'selected': false
},
'children': clients
}
]
},
"plugins": ["checkbox"]
});
For click event of checkbox I'm using the below jquery :
$('#FolderTree').on("select_node.jstree", function (e, data) {
var checkedValue = data.node.text;
});
But I want to first determine if the checkbox I've clicked is parent node or child node..How can I do that??
You can use this code:
is_parent
will tell you if the node has any children,is_leaf
will tell you if it is a leaf node (if it has no children) - use one or the other.If you need to check if a node is a root node you can use:
var isRoot = (data.node.parents.length === 1)