Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQUery context menu on left click

I am using jQuery context menu plugin by Chris Domigan to appy a context menu. This is how it works:

$('#contacts tbody tr').contextMenu('myMenu1', {
    bindings: {
        'copy': function(t) {
             alert('Trigger was '+t.id+'\nAction was Copy');
         },

        'delete': function(t) {
             alert('Trigger was '+t.id+'\nAction was Delete');
        }
    },             
});

Now I want this context menu to appear on left click instead of right click. I can not find an option in the doc. Any ideas how to do that? Do I have to modify the source?

like image 899
UpCat Avatar asked Feb 21 '26 06:02

UpCat


1 Answers

I know it's old, but i'll answer it anyways ;)

If you want to call ContextMenu on left-click, just change the line:

$(this).bind('contextmenu', function(e) {

into this:

$(this).bind('click', function(e) {

But if You want to capture more events to display ContextMenu, You can add event names after spacebar, according to jQuery .bind() reference.

For instance, if You want to display the menu on left and right click just change the line into this:

$(this).bind('contextmenu click', function(e) {
like image 78
emen Avatar answered Feb 27 '26 10:02

emen