1

I'm trying to integrate this plugin into my app: https://github.com/mar10/jquery-ui-contextmenu/blob/master/jquery.ui-contextmenu.js

I'm completely baffled as to how right-clicking an element that matches the delegate selector on an initialized element ends up firing the 'contextmenu' event on the bound element... I've been reading this code for HOURS and I'm still not seeing anything like:

ui.target.on('right-click', opt.selector, function(){ this._tigger('contextmenu')});

or something along those lines.. I see no references to event.which() (for mouse button detection) etc..

I can see the custom "contextmenu" event being bound to the delegate on line 79, but I'm not seeing anywhere in the code that shows how this custom even actually gets FIRED upon right-clicking an element...

Since I can't see any triggering code.. I'm assuming the jQuery-UI widget factory is somehow "automagically" doing the triggering.. but that still begs the question, how is this plugin telling the jquery-ui framework, "use right click event as my 'trigger'"??

how in the world is this working????? PLEASE HELP!

6
  • 2
    The event used is oncontextmenu Commented Dec 6, 2013 at 22:41
  • github.com/mar10/jquery-ui-contextmenu/blob/master/… and taphold Commented Dec 6, 2013 at 22:42
  • So @adeneo, doing something like: $(window).on('contextmenu', function(){ .. }); is essentially the same thing as: window.oncontextmenu = function(){ .. } ? Commented Dec 6, 2013 at 22:47
  • Yes, when using jQuery (or addEventListener) you remove the leading "on" and just use the event name, so that seems right. Commented Dec 6, 2013 at 22:50
  • wow.. thank you! this has had my development stalled for two days now! Commented Dec 6, 2013 at 22:53

1 Answer 1

1

The plugin isn't listening for click events, it's listening for the oncontextmenu event which fires whenever the context menu is triggered, which most of the time is whenever something is right clicked

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.