9

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?

웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90

3 Answers3

16

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

periklis
  • 10,102
  • 6
  • 60
  • 68
  • @silver @periklis I want the node to be selected on both button clicks. My question is how do I take different actions depending on which button triggered the `select_node.jstree` event. – Alexander Suraphel Apr 07 '16 at 11:37
  • @AlexanderSuraphel I'm not sure how to do this, why don't you post this as a new question? – periklis Apr 07 '16 at 11:55
  • @periklis that was the original intent of my question! But does making `"select_node":false` appear selected when right clicked? – Alexander Suraphel Apr 07 '16 at 12:32
9

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; 

            ...

        });
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90
0

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.
}
Shree Krishna
  • 8,474
  • 6
  • 40
  • 68