Jquery context menu plugin - Where is the right button event type?

I studied the code for the plugin below and wondered where and when it binds the Right Click event. All he does is

Plugin link link: http://www.javascripttoolbox.com/lib/contextmenu/

$(this).bind('contextmenu',function(e){cmenu.show(this,e);return false;});

and "contextmenu" is a custom jquery event type.

Can someone explain how this all works?

I checked that there are click events, but they are bound to menu items, not to the item to which the menu is bound.

thanks

Answer: "contextmenu" is not a custom event type. Actually this is a different name (matching, etc.) For a "right click"

+4
jquery
source share
2 answers

contextmenu not a jQuery custom event (see here MDC article here ). The whole plugin binds the event handler to this event and shows / hides the menu.

+2
source share

contextmenu is a javascript event that fires when the user right-clicks on an element, if you want to use this event to implement your own function, you can do something like this:

 $("element").bind("contextmenu",function(){ //your code here }); 

what happens in the connection code is the following:

 $(this).bind('contextmenu',function(e){ //capture right click on "this" which //is the element being clicked cmenu.show(this,e); //call function cmenu.show to show the menu and pass two arguments //the element clicked "this: and the event data "e" return false; //this cancels the default context menu }); 
+1
source share

All Articles