开发者

context menu on left mouse click?

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)."

could somebody t开发者_JAVA百科ell me how

  • I can trigger the menu on left mouse click
  • leave the right mouse as it is


Since 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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜