swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.24k stars 744 forks source link

Trigger Menu Open #655

Open aliaezat opened 6 years ago

aliaezat commented 6 years ago

Hi there,

I am trying to create jQuery-contextMenu on daypilot scheduler event (DayPilot.org) but the scheduler context menu is conflicting with it. Basically, daypilot is preventing the contextmenu event propagation. So, my question is, Is there a way I can get jQuery-contextMenu manually without explicitly triggering 'contextmenu' event like in using:

$(".some-selector").contextMenu(); $(".some-selector").contextMenu({x: 123, y: 123});

bbrala commented 6 years ago

Doesn't the code you provided work? That should open the contextmenu manually as mentioned in docs

aliaezat commented 6 years ago

It doesn't work because I have to call it from within a contextmenu event handler which causes an infinit recursion. I need away to open the context menu directly without triggering the 'contextmenu' event.

russelltrafford commented 5 years ago

Agreed, having the same issue here. Ends up with an infinite loop. In my case, setting a listener on contextmenu, and then conditionally deciding whether to open the menu or not (or default browser one instead), and if yes, the only way to trigger the menu is using contextmenu, which calls itself.

So ideally, we should have a function like $contextMenu.show() which is triggered by the contextmenu event, which would allow a developer to trigger it from other places, or handle the contextmenu event themselves.