Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10010 closed bug (invalid)

Double Window.load not working

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: event Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:


  1. The version(s) of jQuery affected: 1.62 and earlier versions
  1. The browser (or browsers) that you are able to reproduce the bug in, including version numbers: FF 5.01 and other browsers
  1. The operating system (or operating systems) you experienced the bug on: OS X LION and other OS
  1. Step-by-step instructions on how to reproduce the issue, including any required system configuration changes:

$(window).load() is called again because of various reasons. Mine is that a form loaded once and then may be reloaded again using ajax call.

Basically it can be reproduced using 2 files - A) Form.php B) Fields.php . File A will include File B using #include ... upon browser load, the window.load found in B will execute perfectly. However, using various Ajax to replace HTML calling file B again, the HTMLS will be loaded properly however window.load does not occur anymore.

  1. A description of what you expect to happen, and what actually happens: Contents of $(window).load() should be executed even if the window was formerly loaded
  1. Sample simplified version using only one file to demonstrate: http://jsfiddle.net/wUyzU/

        $("#content").append(" Again! ");


        $("#content").append(" Twice!");                  


Change History (4)

comment:1 Changed 11 years ago by Rick Waldron

Component: unfiledevent
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

I don't think it makes sense for jQuery to add code to handle such an edge case. Either way, it works properly when they're no nested:


comment:2 Changed 11 years ago by [email protected]

Hi rwaldron,

I think the scenario makes sense. Although the sample given is nested. Imagine in which a user may load through ajax a html with scripts having $(window).load() and not $(document).ready();

comment:3 Changed 11 years ago by dmethvin

Resolution: wontfix
Status: closedreopened

comment:4 Changed 11 years ago by dmethvin

Resolution: invalid
Status: reopenedclosed

The semantics of the .ready() method are different from those of the load event. Once the document becomes ready it stays ready. It's not an event, but a state. Any ready handler attached at any point afterwards will run immediately.

The load event is different; a load event is fired *once* by the browser. A new handler attached then, or anywhere afterwards, will not fire because the browser never fires load again.

Although a ready *event* does exist and you can attach to it with .bind(), it fires once the same way the load event does. You should use .ready() instead.

Note: See TracTickets for help on using tickets.