I'm displaying a contextmenu in jQuery, but am unable to close it.
These are the events that I am registering:
<!-- language: lang-js -->function openContextMenu(event) {
event.preventDefault();
$("#custom-menu")
.css({
top: event.pageY + "px",
left: event.pageX + "px"
})
.show(100);
isContextMenuOpen = true;
}
function closeContextMenu(event) {
console.log("Click called on document");
if (isContextMenuOpen) {
$("custom-menu").hide();
console.log("Hide the context menu");
}
isContextMenuOpen = false;
}
function registerMenu() {
$(document).on({
contextmenu: function (event) {
openContextMenu(event);
},
click: function (event) {
closeContextMenu(event);
}
});
}