Failing to run the document ready functions is a bug in jQuery 1.3.2 that is
fixed in the current svn. It now calls document.ready listeners even if you
load jQuery and subsequent document ready functions dynamically.

At least I *assume* that it's a bug that was fixed, and not just an
accidental improvement! :-)

Try your code with the nightly you can get here:

http://docs.jquery.com/Downloading_jQuery#Nightly_Builds

Regarding the onload for the script, the best way to handle this is to make
a custom copy of jquery.js or jquery.min.js and add a line to the end:

window.jQueryLoaded && jQueryLoaded();

Then you provide a global jQueryLoaded() function before loading jQuery, and
that has your other initialization code (using document ready if you want
with the new jQuery code).

Or you can add whatever initialization code you want at the end of your
jquery.js file.

-Mike

p.s. Speaking of jQuery svn, are there nightly builds or the like

On Thu, Oct 8, 2009 at 6:11 AM, Ryan Crumley <crum...@gmail.com> wrote:

>
> Rob,
>
> Point taken about using onLoad for a script tag possibly not being
> supported. In this case however that part of the code is working fine.
> The issue I am having is related to jQuery being added to a page after
> the page has completed loading. When this happens ready listeners are
> never executed. If jQuery is present when the page loads then ready
> listeners are executed as expected.
>
> Ryan
>
> On Oct 8, 12:45 am, RobG <robg...@gmail.com> wrote:
> > On Oct 8, 10:04 am, Ryan Crumley <crum...@gmail.com> wrote:
> >
> > > I am experiencing unexpected behavior using $(document).ready() on a
> > > page where I inject jQuery after the page has loaded and then attach
> > > listeners to the ready event. The ready() event is never called using
> > > Firefox and Safari however it is called using IE.
> > [...]
> > >                 function loadjquery() {
> > >                         var url = "
> http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
> > > jquery.js";
> > >                         var head =
> document.getElementsByTagName("head")[0], done = false;
> > >                         var script = document.createElement("script");
> > >                         script.src = url;
> >
> > >                         script.onload = script.onreadystatechange =
> function() {
> >
> > There is no onload attribute for script elements defined in HTML 4.01,
> > therefore you should not expect that a script element will fire a load
> > event. The fact that some browsers do and some don't should be enough
> > to tell you that browser behaviour is inconsistent.  You are unlikely
> > to be able to reliably fix that with script.
> >
> > If you want a reliable indicator that a script has finished loading
> > and is ready for use, put a statement at the bottom like:
> >
> >   var SCRIPT_LOADED = true;
> >
> > --
> > Rob
>

Reply via email to