context menu on left mouse click?

时间:2022-09-25 20:22:09

the description of jsTree contextmenu says "The contextmenu plugin enables a contextual menu to be shown, when the user right-clicks a node (or when triggered programatically by the developer)."

jsTree contextmenu的描述说:“当用户右键单击一个节点时(或者当开发人员以编程方式触发时),contextmenu插件可以显示上下文菜单。”

could somebody tell me how

有人可以告诉我怎么样

  • I can trigger the menu on left mouse click
  • 我可以在鼠标左键单击时触发菜单

  • leave the right mouse as it is
  • 保持鼠标原样

3 个解决方案

#1


5  

Since JSTree 3

自JSTree 3

$('#jstree_list').jstree({
   ...
}).on('select_node.jstree', function (e, data) {
    setTimeout(function() {
        data.instance.show_contextmenu(data.node)
    }, 100);
});

The delay seems necessary, I don't know exactly why

延迟似乎是必要的,我不知道究竟为什么

#2


1  

You can trigger context menu on elem (eg. a <li>) by $(elem).trigger('contextmenu.jstree')

您可以通过$(elem).trigger('contextmenu.jstree')触发元素上的上下文菜单(例如a

  • )

  • #3


    1  

    Had the same issue. Here's how you do it:

    有同样的问题。这是你如何做到的:

    element.jstree({
      .
      .
      .
    }).bind("select_node.jstree", function (event, data) {
      setTimeout(function() {data.rslt.obj.children('a').trigger('contextmenu')}, 100);
    });
    

    Note that the triggering is done in a setTimeout(). It did not work for me otherwise.

    请注意,触发是在setTimeout()中完成的。否则它对我不起作用。

    #1


    5  

    Since JSTree 3

    自JSTree 3

    $('#jstree_list').jstree({
       ...
    }).on('select_node.jstree', function (e, data) {
        setTimeout(function() {
            data.instance.show_contextmenu(data.node)
        }, 100);
    });
    

    The delay seems necessary, I don't know exactly why

    延迟似乎是必要的,我不知道究竟为什么

    #2


    1  

    You can trigger context menu on elem (eg. a <li>) by $(elem).trigger('contextmenu.jstree')

    您可以通过$(elem).trigger('contextmenu.jstree')触发元素上的上下文菜单(例如a

  • )

  • #3


    1  

    Had the same issue. Here's how you do it:

    有同样的问题。这是你如何做到的:

    element.jstree({
      .
      .
      .
    }).bind("select_node.jstree", function (event, data) {
      setTimeout(function() {data.rslt.obj.children('a').trigger('contextmenu')}, 100);
    });
    

    Note that the triggering is done in a setTimeout(). It did not work for me otherwise.

    请注意,触发是在setTimeout()中完成的。否则它对我不起作用。