Bug Tracker

Opened 14 years ago

Closed 13 years ago

Last modified 11 years ago

#3861 closed bug (fixed)

.live('click', function) conflicts with mousedown event

Reported by: walidaly Owned by:
Priority: major Milestone: 1.4.1
Component: event Version: 1.4
Keywords: Cc:
Blocked by: Blocking:

Description

on the main tutorial example on http://docs.jquery.com/Events/live click with your middle mouse button or right click on the "P" element you will see same effect

Change History (11)

comment:1 Changed 14 years ago by john

Component: unfilledevent
Milestone: 1.31.3.1
Resolution: worksforme
Status: newclosed
Version: 1.2.61.3

Yep - that's to be expected. Any binding of a click handler will capture all clicks (not just left clicks).

comment:2 Changed 14 years ago by walidaly

but then what's the different between 'mousedown' and 'click' event? is that a JavaScript problem or JQuery? Specially, using window.open() inside the 'click' binding will make Firefox popup blocker stop the event

comment:3 Changed 14 years ago by glavic

Resolution: worksforme
Status: closedreopened

this must be bug, because if I use "bind('click', ...)" it work only with left click and not with other mouse clicks like right or middle click.

comment:4 Changed 14 years ago by dmethvin

It seems like Firefox does not fire a click event for the element on a right-click, although it fires a mousedown and mouseup. However, it *does* fire a click event on document! Since .live catches events at the document level, it sees the click event for the element even though the element itself does not. If you use an event like mouseup, both the p element and the document will see the event.

I agree this seems like a bug, but if so it's a browser bug. Here's a recent article describing the situation.

http://unixpapa.com/js/mouse.html

comment:5 Changed 14 years ago by brandon

See also #4197 which was closed as duplicate of this bug

comment:6 Changed 13 years ago by Wardrop

I also posted a duplicate: http://dev.jquery.com/ticket/5461

comment:7 Changed 13 years ago by petersendidit

There are 2 tickets in bugzilla for Firefox and the click event getting fired on the document when you middle or right click. https://bugzilla.mozilla.org/show_bug.cgi?id=503026 https://bugzilla.mozilla.org/show_bug.cgi?id=485980

comment:8 Changed 13 years ago by iraebrasil

Still happening on 1.4.

Also, I think worth to note that jQuery is supposed to circumvents cross browser issues. This in most cases means workaround IE problems. This time our beloved Firefox is at stake but, IMHO jQuery sould fix it anyway.

I've debugged, made a patch and test cases. Submited to my fork on github: http://github.com/irae/jquery/commit/e94b1e7c320b78580a3fac1afc2b6a3bee4dc140

Tested on Firefox 3.5.7, IE6 and Chrome (win XP).

With github, is it necessary to submit the patch here on the bugtracker?

comment:9 Changed 13 years ago by tomsomething

I agree with iraebrasil. Might be Firefox's fault, and Firefox might fix it in a later version, but we can't count on all of our site visitors staying up-to-date with the latest browser. *cough* IE6, for example *cough* If it's adressed in a jQuery patch, that puts a solution in the hands of the developers, and we're good with that stuff.

comment:10 Changed 13 years ago by john

Milestone: 1.3.11.4.1
Resolution: fixed
Status: reopenedclosed
Version: 1.31.4

comment:11 Changed 12 years ago by dmethvin

#5885 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.