Diego Donate
Programmer
Hi,
I have an application with some HTML/js code. I am using jquery to show a contextmenu ( in the $document element when I rightclick in a div of this document. With 'autohide' it closes when mouse leaves the HTML document, but I would like to close the context menu in some other situations, but I don't know how to close the menu programatically.
My code:
$(document).contextMenu({ selector: '#' + panelId, autoHide: true, items: ... callback: function(key, options) { if (key === ... }
I have a function where I need to close the menu, but all my tests fail:
function() { $(document).contextmenu(false); $(document).trigger('contextmenu:hide'); $trigger = $('#' + panelId); $trigger.contextMenu(false); } 'panelId' is a value I get when I rightclick in the div, using 'oncontextmenu' attribute with 'myFunction' value. So 'myFunction' is called before displaying the context menu, and I save there the id, to be used to enable/disable items when the menu is 'about to show'
I hope someone could help me about how to close the menu,
Thanks in advance,
Diego
I have an application with some HTML/js code. I am using jquery to show a contextmenu ( in the $document element when I rightclick in a div of this document. With 'autohide' it closes when mouse leaves the HTML document, but I would like to close the context menu in some other situations, but I don't know how to close the menu programatically.
My code:
$(document).contextMenu({ selector: '#' + panelId, autoHide: true, items: ... callback: function(key, options) { if (key === ... }
I have a function where I need to close the menu, but all my tests fail:
function() { $(document).contextmenu(false); $(document).trigger('contextmenu:hide'); $trigger = $('#' + panelId); $trigger.contextMenu(false); } 'panelId' is a value I get when I rightclick in the div, using 'oncontextmenu' attribute with 'myFunction' value. So 'myFunction' is called before displaying the context menu, and I save there the id, to be used to enable/disable items when the menu is 'about to show'
I hope someone could help me about how to close the menu,
Thanks in advance,
Diego