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;
}
}
}
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:
should be:
Also to disable the context menu use the following on the selected jquery object:
So in your case instead of using unbind use: