1

I use a plugin for jQuery - ContextMenu. - http://abeautifulsite.net/blog/2008/09/jquery-context-menu-plugin/

I want to do on the button - click event - an event contextMenu cancel.

I tried this code: (This does not work correctly.)

JS

$("#btnUnbind").click(function () {
    $('.icon').unbind('contextMenu');
});

HTML

<ul id="myMenu" class="contextMenu">            
    <li class="delete"><a href="#delete">Delete</a></li>            
</ul>

JS

  $(".icon").contextMenu(
                    { 
                        menu: 'myMenu' 
                    }, 
                    function(action, el, pos) 
                    { 
                        contextMenuWork(action, el, pos); 
                    });

     function contextMenuWork(action, el, pos) {
                switch (action) {
                    case "delete":
                        {
                            break;
                        }
                }
     }

1 Answer 1

1

In your 1st and 2nd javascript you select .icon, this doesn't exist in your HTML example.

Also in the 2nd javascript you forgot to put .icon between quotes:

$(.icon)

should be:

$('.icon')

Also to disable the context menu use the following on the selected jquery object:

.disableContextMenu();

So in your case instead of using unbind use:

$('.icon').disableContextMenu();
Sign up to request clarification or add additional context in comments.

1 Comment

Ah ok, well to disable your contextMenu see my edited answer.

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.