Side navigation
#13985 closed bug (notabug)
Opened June 04, 2013 01:26AM UTC
Closed June 04, 2013 02:50AM UTC
Last modified June 04, 2013 07:20AM UTC
Two versions of jQuery and the $.noConflict causes some weird behavior on link clicks
Reported by: | netlovers | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I created a sample here: http://jsfiddle.net/3ksqX/3/
The problem is, when I call .click() on a link with the noconflicted version of jquery, the previously attached event doesn't run (.trigger('click') doesn't work either).
If I do the same with a button, then the counter increases (in the example).
I did some digging, and this is the line, where everything stops:
https://github.com/jquery/jquery/blob/master/src/event.js#L564
What is the expected behavior?
Attachments (0)
Change History (2)
Changed June 04, 2013 02:50AM UTC by comment:1
resolution: | → notabug |
---|---|
status: | new → closed |
Changed June 04, 2013 07:20AM UTC by comment:2
I saw the other ticket, but this really seems inconsistent to me, because it works with other elements, but not with links.
And it is sad, but I don't really have any knowledge about the other jQuery versions. I mean, I could write some
if (!jQuery) { doc.write('<script src="own-jquery.js"></scr'+'ipt>'); }
code but it seemed a bad idea. And then I have to put up with all the old versions of jQuery's quirks, not to mention if for some reason they use $.noConflict too, when attaching event listeners, than there is no way of triggering a click event, that runs all the handlers that were attached is any way. At least not with jQuery. This is so sad.
But, thank you really!
This is expected behavior. Updated test case: http://jsfiddle.net/3ksqX/5/
Each copy of jQuery has its own event list. When you manually
.trigger("click")
or.click()
the copy of jQuery does most of the work. It has to:onclick
handlers.window
.event.preventDefault()
. See #12652 for why this exception exists.If you need to bridge two copies of jQuery you could a click handler on one copy that triggered a similar click on the other jQuery copy. Really though, two copies of jQuery in a page should be avoided.