Ticket #9382 (closed bug: worksforme)
Click isn't triggered with mouse but it's ok by code
| Reported by: | laligatz@… | Owned by: | laligatz@… |
|---|---|---|---|
| Priority: | low | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.6.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hi,
I am trying to develop a large application in JS and I have some menus interactions. All was working fine with jQuery 1.5.2, but with jQuery 1.6.1, the click binding on my menu doesn't work. After investigations, the moment where I bind the click event just after the creation of the <a/> tag no longer seems to be the right place. If I do the bind *after* all the stuff was done, in Firebug for example, it works. What i do not understand it's why. If I dump the element, i see its click event attached in the data property. Even if i do mymenu.click() in the console, it's working. But a real click with my mouse doesn't !
I've tried to use promise().done(function{}) sequence for building my HTML elements, but without success.
I've spent a lot of hours to try to understand what is going wrong. I'll have to change the logic of my menus creation but I don't know if I'm missing something or if i found a bug in jQuery.
Change History
comment:1 Changed 2 years ago by addyosmani
- Owner set to laligatz@…
- Priority changed from undecided to low
- Status changed from new to pending
comment:2 Changed 2 years ago by anonymous
Ok, i've just found the solution.
I clone my anchor and i lost the event click at this time. With .clone(true, true), everything is working. But with jQuery 1.5.1, no need to set true to clone() function, the events are still copied. Perhaps, it was a bug which has been fixed !
comment:3 Changed 2 years ago by rwaldron
- Status changed from pending to closed
- Resolution set to worksforme
That was a mistake that *I* caused in the clone() rewrites, where I handled the args backwards. The issue was detected after the code shipped and was quickly patched. Sorry for the confusion and inconvenience.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for submitting a ticket to the jQuery Project. We're unfortunately unable to assist with debugging problems that haven't been reduced down to a runnable test case, however if you're able to supply us with this (via http://jsfiddle.net), we'll do our best to evaluate whether this is an issue with jQuery core or not.