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 tell me how
- I can trigger the menu on left mouse click
- leave the right mouse as it is
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 tell me how
- I can trigger the menu on left mouse click
- leave the right mouse as it is
- Please stop writing tags in question titles. – Lightness Races in Orbit Commented Apr 23, 2011 at 0:37
3 Answers
Reset to default 5Since 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.