You can enable node opening/closing on the label click using the UI plugin and binding the select_node.jstree event to your tree. A consequence of this method means that any leafs with a valid HREF attribute will no longer click through as expected.
The method below demonstrates how to have a toggle action on clicking a node, and still allowing a click on a leaf node to (in this case) start a file download.
$('#tree').jstree({
plugins: ['themes','xml_data'],
xml_data: {
ajax: {
url: '/path/to/xmlresponse'
}
}
});
$("#tree").delegate("a","click", function (e) {
if (this.className.indexOf('icon') == -1) { // is the node clicked a leaf?
$("#tree").jstree("toggle_node", this);
e.preventDefault();
return false;
}
});
2 Comments
Great! Thanks.
Sweet! and easy too! Thanks!