1

I am using this contextmenu plugin: http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/

DEMO: http://labs.abeautifulsite.net/projects/js/jquery/contextMenu/demo/

SOURCE-CODE: http://labs.abeautifulsite.net/projects/js/jquery/contextMenu/demo/jquery.contextMenu.js

DEFAULT CALL:

$("#myDiv").contextMenu({
                    menu: 'myMenu'
                },
                    function(action, el, pos) {
                    alert(
                        'Action: ' + action + '\n\n' +
                        'Element ID: ' + $(el).attr('id') + '\n\n' + 
                        'X: ' + pos.x + '  Y: ' + pos.y + ' (relative to element)\n\n' + 
                        'X: ' + pos.docX + '  Y: ' + pos.docY+ ' (relative to document)'
                        );
                });

I want to call this context menu on a left click rather than a right click, how can I achieve this ? or any other plugin suggestions?

1

2 Answers 2

1

Do a regular click handler:

$("#myDiv").on('click', function() {
    $(this).contextmenu(...)
})
Sign up to request clarification or add additional context in comments.

1 Comment

That will only attach contextmenu() function to #MyDiv when I left-click. The function itself is listening to right-click.
0

Inside the source code, looking for the following codes:

if( evt.button == 2 ) {...

According to W3C its values should be:

Left button = 0,

Middle button = 1,

Right button = 2,

According to Microsoft its values should be:

Left button = 1,

Middle button = 4,

Right button = 2,

You may change the value depending on what you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.