Skip to main content

Bug Tracker

Side navigation

#8668 closed enhancement (patchwelcome)

Opened March 27, 2011 05:11AM UTC

Closed March 29, 2011 12:53PM UTC

Last modified May 08, 2011 06:01AM UTC

Make click and dblclick events work properly with any browser when they both have a handler for the same element

Reported by: cfreed@orange.fr Owned by: cfreed@orange.fr
Priority: low Milestone: 1.next
Component: event Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:
Description

Having an application where both click and dblclick event were expected on the same element, I realized that it worked or not, depending on which browser I used.

So I looked for information, and I successively found 2 contradictory advices in jQuery documentation!

  • in dblclick() page is advised not to use the 2 events on the same element
  • in bind() page is presented an example of this double use

I then investigated, and I seem having understood where the problem lies, and found a simple method to get it working always properly.

So I think that jQuery could integrate the involved mechanism to automatically apply it as soon as a it sees that the 2 events are bound on the same element.

Please look at for all details on how I understand the problem and how I get around it.

Thanks for your attention

Attachments (0)
Change History (5)

Changed March 27, 2011 02:36PM UTC by rwaldron comment:1

component: unfiledevent
description: Having an application where both click and dblclick event were expected on the same element, I realized that it worked or not, depending on which browser I used. \ \ So I looked for information, and I successively found 2 contradictory advices in jQuery documentation! \ - in dblclick() page is advised not to use the 2 events on the same element \ - in bind() page is presented an example of this double use \ \ I then investigated, and I seem having understood where the problem lies, and found a simple method to get it working always properly. \ \ So I think that jQuery could integrate the involved mechanism to automatically apply it as soon as a it sees that the 2 events are bound on the same element. \ \ Please look at https://forum.jquery.com/topic/both-click-and-dblclick-where-is-the-truth for all details on how I understand the problem and how I get around it. \ \ Thanks for your attentionHaving an application where both click and dblclick event were expected on the same element, I realized that it worked or not, depending on which browser I used. \ \ So I looked for information, and I successively found 2 contradictory advices in jQuery documentation! \ - in dblclick() page is advised not to use the 2 events on the same element \ - in bind() page is presented an example of this double use \ \ I then investigated, and I seem having understood where the problem lies, and found a simple method to get it working always properly. \ \ So I think that jQuery could integrate the involved mechanism to automatically apply it as soon as a it sees that the 2 events are bound on the same element. \ \ Please look at for all details on how I understand the problem and how I get around it. \ \ Thanks for your attention
owner: → cfreed@orange.fr
status: newpending

Please provide a reduced test case on http://jsfiddle.net (be sure to use jQuery Edge) thanks!

Changed March 27, 2011 10:35PM UTC by cfreed@orange.fr comment:2

status: pendingnew

You may look at http://jsfiddle.net/cFreed/ky7xh/.

CAUTION: uses jQuery-1.5.1, rather than jQuery Edge as required.

For me, using jQuery Edge fires an error with any simple HTML content:

"uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://code.jquery.com/jquery-git.js :: anonymous :: line 1285" data: no]"

Changed March 29, 2011 12:53PM UTC by dmethvin comment:3

keywords: → needsdocs
priority: undecidedlow
resolution: → patchwelcome
status: newclosed

Re comment #2, that is a bug and has already been filed/fixed for 1.5.2.

I agree we're giving contradictory information, the example in http://api.jquery.com/bind/ does attach both handlers even though the text in http://api.jquery.com/dblclick/ warns about cross-browser issues. I do not think this is something worth normalizing, but if you would like to propose a solution (perhaps initially in a plugin) we could consider it.

Changed March 30, 2011 01:59PM UTC by cfreed@orange.fr comment:4

Replying to [comment:3 dmethvin]:

Re comment #2, that is a bug and has already been filed/fixed for 1.5.2. I agree we're giving contradictory information, the example in http://api.jquery.com/bind/ does attach both handlers even though the text in http://api.jquery.com/dblclick/ warns about cross-browser issues. I do not think this is something worth normalizing, but if you would like to propose a solution (perhaps initially in a plugin) we could consider it.

Not sure to well understand what you mean when you "do not think this is sometingu worth normalizing".

May be I'm wrong but, from what I investigated, I seem that in the current state (no special survey), the risk of dysfunction when attaching both handlers is quite confirmed. So it will be worth to have a definitive solution to eliminate it, isn't it?

If yes, my only doubt is about the real efficacity of my own solution.

As a simple application developper, I'm obviously much less experienced than jQuery contributors. It is why I need your opinion: does it seem to you that my solution covers all aspects of the problem?

Particularly, apart from the simple timing issue, I investigated about the problem of different browsers receiving one or two clicks before firing dblclick (look at my updated test case http://jsfiddle.net/ky7xh/7/): seems that it doesn't matter.

But perhaps I'm blind to other aspects...

So once again your opinion should be very welcome.

Thanks in advance.

Changed May 08, 2011 06:01AM UTC by addyosmani comment:5

keywords: needsdocs

For the time-being, I've updated .bind() to reflect a similar note to the one we've included on dblclick and added a reference to the example that uses them. We should however consider (imo) dropping the example that binds both handlers as it doesn't really make sense to tell people not do something then show an example that contradicts this :) http://api.jquery.com/bind/