Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#4197 closed bug (duplicate)

live events' "click" handler catches right clicks (unlike normal click event)

Reported by: jicksta Owned by: brandon
Priority: major Milestone: 1.3.2
Component: event Version: 1.3.1
Keywords: live, click, event Cc:
Blocked by: Blocking:

Description

You can test it out yourself:

http://docs.jquery.com/Events/live

If you right click the example "Click me!" element, it'll trigger the "click" event. Now, right click one of example elements on this page:

http://docs.jquery.com/Events/click

Only the live click event reacts to the right click. I first noticed this when using Firebug to inspect an element that had a live event defined on it. Not being able to easily inspect an element anymore is quite painful. :)

Major kudos on jQuery, though! It makes Javascript fun again. :)

Change History (5)

comment:1 Changed 11 years ago by aheimlich

I came across this issue as well in my current project. I noticed that it only occurs when binding to document and only in Firefox (confirmed on Mac OS, not sure about Windows)

comment:2 Changed 11 years ago by Ubercore

I see this also on Firefox in Mac OS. I'm seeing it for regular a tags though, not just document.

comment:3 Changed 11 years ago by iraebrasil

Same problem here!

I've created an test case before finding this bug. The case is here: http://jquery.nodnod.net/cases/284

I didn't had the time to look into it yet on jQuery source code, but I'm using an nasty workaround for now. Really nasty!

// Fix for .live() bug with right click on Firefox,
// because right click it's not a click!
jQuery.fn.__live__ = jQuery.fn.live;
jQuery.fn.live = function(type,fn) {
	if(type != 'click') {
		return this.__live__(type, fn);
	} else {
		var anti_right_click_callback = fn;
		var anti_right_click_proxy = function(e) {
			if(e && e.button && e.button === 2) {
				e.preventDefault();
				e.stopPropagation();
				return false;
			} else {
				anti_right_click_callback.call(this, e);
			}
		};
		return this.__live__(type, anti_right_click_proxy);
	}
};

This is of course the incorrect approach to jQuery, but someone desperate for a solution my have some usefullness to it.

comment:4 Changed 11 years ago by dmethvin

See also #3861 for some related info.

comment:5 Changed 11 years ago by brandon

Resolution: duplicate
Status: newclosed

Closing, duplicate of #3861

Note: See TracTickets for help on using tickets.