Side navigation
#7247 closed bug (fixed)
Opened October 19, 2010 12:55AM UTC
Closed October 22, 2010 04:08AM UTC
Last modified March 19, 2012 09:22PM UTC
function bound to ready event fires twice on 1.4.3
Reported by: | dustymugs | Owned by: | gf3 |
---|---|---|---|
Priority: | blocker | Milestone: | 1.4.4 |
Component: | core | Version: | 1.4.3 |
Keywords: | regression | Cc: | |
Blocked by: | Blocking: |
Description
I'm currently using Firefox 3.6.10 and Opera 10.60 on Slackware Linux 12.1.
In jQuery 1.4.2, a function bound to the document ready event fires once. The same is not true in 1.4.3. A simple test case can be found at:
[
For the test case above, the jquery version number should appear only once. It shows up twice for 1.4.3.
Attachments (0)
Change History (17)
Changed October 19, 2010 01:00AM UTC by comment:1
component: | unfiled → core |
---|---|
keywords: | → regression |
milestone: | 1.5 → 1.4.4 |
priority: | undecided → blocker |
status: | new → open |
Changed October 19, 2010 01:12AM UTC by comment:2
$(document).bind( 'ready', fn )
not only double-fires, but bound handlers also execute out-of-order. Note that $(document).ready( fn )
and $( fn )
seem fine.
Changed October 19, 2010 08:22AM UTC by comment:3
Confirmed in Opera 10.63, FF 4.04b, FF 3.6.10, Chrome and IE6 on Windows XP.
All show the same behavior. "ready bind bind" for snovers test case and the same order cowboy documented on his test-case
Changed October 19, 2010 09:36AM UTC by comment:4
I use $(function(){}); in ie 7.0, the ready event is also double fires.
But sometimes OK, sometimes fail...the only way is back to v1.4.2....
Changed October 22, 2010 12:52AM UTC by comment:5
owner: | → gf3 |
---|---|
status: | open → assigned |
Changed October 22, 2010 04:08AM UTC by comment:6
resolution: | → fixed |
---|---|
status: | assigned → closed |
Make sure that the ready event doesn't double-fire when .bind(ready) is used. Fixes #7247.
Changeset: 3df41db0369cfaf0fc229c633eb87f222ad49357
Changed October 22, 2010 04:10AM UTC by comment:7
Will deal with the out-of-order events over here: #7279 (that was an issue in 1.4.2 and earlier as well - it will require a lot more work, should go into 1.5, probably).
Changed October 27, 2010 12:57PM UTC by comment:9
I've tried apply the changes from the changeset to my code, but the event still fires twice.
In fact, before applying it it would seem to sometimes fire twice, and afterwards it is always firing twice.
I have tried both $(document).ready and $(document).bind('ready'
Is there anything I am doing wrong?
Changed October 27, 2010 02:09PM UTC by comment:10
description: | I'm currently using Firefox 3.6.10 and Opera 10.60 on Slackware Linux 12.1. \ \ In jQuery 1.4.2, a function bound to the document ready event fires once. The same is not true in 1.4.3. A simple test case can be found at: \ \ [http://dev.calsurv.org/debug.html] \ \ For the test case above, the jquery version number should appear only once. It shows up twice for 1.4.3. → I'm currently using Firefox 3.6.10 and Opera 10.60 on Slackware Linux 12.1. \ \ In jQuery 1.4.2, a function bound to the document ready event fires once. The same is not true in 1.4.3. A simple test case can be found at: \ \ [ \ \ For the test case above, the jquery version number should appear only once. It shows up twice for 1.4.3. |
---|
Can you test this with http://code.jquery.com/jquery-git.js
Changed October 27, 2010 04:30PM UTC by comment:11
OK, I tried with that, and it still happened.
But then I played around a bit more, and it seems the problem was I was using an alert to check if it fired twice, and I kept getting two alerts. I switched to using console.log and only one message was logged. I combined both, so had an alert and a log in the handler, and got two alerts and two logs to the console.
So, it seems it is the alert that is causing the problem for me. I guess because it holds up execution of the handler, so the unbind doesn't happen until the alert is called.
I'm new to jQuery, so don't know enough of the inner workings to know if there is a clever workaround for this. Although, I've also only just discovered console.log, and so will probably be using that instead of alert from now on anyway, so may not encounter the problem again.
Changed November 03, 2010 07:17PM UTC by comment:12
I can confirm the bug still remains in IE 6-9 (in IE8 always)
Sample: http://pastebin.com/sa2Ays8M
Changed November 08, 2010 02:28PM UTC by comment:13
Replying to [comment:12 nAS]:
I can confirm the bug still remains in IE 6-9 (in IE8 always) Sample: http://pastebin.com/sa2Ays8M
i confirm bug with jquery 1.4.4rc2
Changed November 21, 2010 09:47PM UTC by comment:14
I can't reproduce this on IE6.
Changed February 08, 2011 10:04AM UTC by comment:15
Bug confirmed in Safari 5.0.3.
Changed February 08, 2011 10:13AM UTC by comment:16
The bug seems to happen only when alert()
is used in the callback. When logging is used it gets executed only once - exactly as stated above.
Furthermore, it does not matter whether we use $(function () {})
or $(document).ready(function (){})
.
Changed February 23, 2011 01:17PM UTC by comment:17
I seem to be having the problem even if I do not use alert. But it does not happen on all instances of $(document).ready and $(function().
improved test case