Ticket #8698 (closed bug: invalid)
Bind not firing immediately with 'ready'
| Reported by: | ErikEckhardt | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This works as expected, calling the function immediately if the ready event has already passed:
$(document).ready(function() {alert('hi');});
But this does not work in my web page on page reload:
$(document).bind('ready.label', function() {alert('hi');});
On my initial page launch it works (most likely because the ready event hasn't "fired" yet?). But on reload, when stuff happens faster because nothing has to be re-downloaded, it just sits there and stares at me. I am using FireFox 3.6.16.
I created a jsFiddle for this, but it doesn't have the problem, most likely because the page is too simple. I put the source of the iframe from jsFiddle into a static html page on my web server and reloads always worked fine. So that is no help to figuring out the problem, sorry about that.
However, please believe me that my application does not work on reload when I use bind and it DOES work when I use ready, the ONLY change between working and not working.
Change History
comment:2 Changed 2 years ago by timmywil
The problem with using .bind('ready') has been documented. See http://api.jquery.com/ready at the bottom of the initial description. It is recommended that you use $(document).ready(handler) or $(handler).
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Note: in my web page I am not just doing a simple alert. It is a complex ajax application that loads a bunch of content dynamically.