How to make jstree to select node only by left-clicking?

Currently, both left and right click select node, which interferes with the context, as I use left clicks to go to other pages. How do I make the select_node.jstree event know which mouse button is clicked?

+8
javascript jquery jstree
source share
3 answers

Since I wanted the click event to be fired by left-clicking, I return false when the click event is fired for a right-click.

 $("#orgTree").bind("select_node.jstree", function(event, data) { var evt = window.event || event; var button = evt.which || evt.button; if( button != 1 && ( typeof button != "undefined")) return false; ... }); 
+5
source share

You can also use "select_node": false in the "contextmenu" section in jstree settings to disable node activation with a right click

see jstree for this

+15
source share

There is a new event (itemClick) , available from version 4.0.0, released to handle only left-click!

 $('#jqxWidget').bind('itemClick', function (event) { //Other codes goes here. } 
0
source share

All Articles