简体   繁体   中英

How do I make jstree to select node only on left click?

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

You can also Use "select_node":false in the "contextmenu" section of your jstree settings to disable activating the node with the right click

see jstree documentation for this

Because I wanted the click event to be fired on left click I return false when the click event is fired for 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; 

            ...

        });

There is new event (itemClick) available since version 4.0.0 released for handling left click only !

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM