Reputation: 61
I'm binding a mouse click listener to serveral SVG elements and - on a click- trigger the open method of a kendo context menu. If the menu is already open (I listening to the activate/deactivate events to check if the menu is open), and the user clicks on the same element , it shall close.
The problem is: the context menu closes by default on mouse down. So when it is open, the user clicks on the same element it closes on mousedown and reopen on mouseup - but it shall close on click, not mousedown. Is there a way to tell this to the context menu directly or do I have to control this by the events of the SVG elements? thanks!
Upvotes: 2
Views: 2195
Reputation: 18402
Not sure I understand what you're trying to do, but you can influence whether the menu closes when you click outside of the menu like this:
kendo.ui.ContextMenu.fn._closeHandler = function (closeHandler) {
return function(e) {
var clickInMenu = $.contains(this.element[0], e.target);
if (clickInMenu) { // click outside will do nothing
closeHandler.call(this, e);
}
}
}(kendo.ui.ContextMenu.fn._closeHandler);
var contextMenu =$("#context-menu").kendoContextMenu({
target: "#target"
});
(demo)
Upvotes: 1