Google Groups Home Help | Sign in
Automatic $(document).ready
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Sam Collett  
View profile
 More options Feb 13 2007, 12:32 pm
From: "Sam Collett" <sam.coll...@gmail.com>
Date: Tue, 13 Feb 2007 17:32:48 +0000
Local: Tues, Feb 13 2007 12:32 pm
Subject: [Dev] Automatic $(document).ready
I have seen a few times that some are not putting code in
$(document).ready, so are sometimes asking why their code does not
work, e.g. you may see this
...
<script type="text/javascript">
$("#mydiv").slideDown();
</script>
</head>
<body>
<div id="mydiv">...

Would it be possible for jQuery to delay execution if no element is
matched and the page isn't fully loaded? That way #myDiv will slide
down as expected.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Miller  
View profile
 More options Feb 13 2007, 12:43 pm
From: "Brian Miller" <bjmil...@bway.net>
Date: Tue, 13 Feb 2007 12:43:09 -0500 (EST)
Local: Tues, Feb 13 2007 12:43 pm
Subject: Re: [Dev] Automatic $(document).ready
I disagree.  There are times, albeit rare ones, when you want to do some
things before the document is ready.  Any attempt to do so, however,
should console.log a warning, because that's not what you want most of the
time.

- Brian


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Collett  
View profile
 More options Feb 13 2007, 1:57 pm
From: "Sam Collett" <sam.coll...@gmail.com>
Date: Tue, 13 Feb 2007 18:57:58 +0000
Local: Tues, Feb 13 2007 1:57 pm
Subject: Re: [Dev] Automatic $(document).ready
On 13/02/07, Brian Miller <bjmil...@bway.net> wrote:

> I disagree.  There are times, albeit rare ones, when you want to do some
> things before the document is ready.  Any attempt to do so, however,
> should console.log a warning, because that's not what you want most of the
> time.

> - Brian

That's why I suggested only to wait if the element is not found. So
with the following, the div is slid down before the document is ready:

<div id="mydiv">
...
</div>
<script type="text/javascript">
$("#mydiv").slideDown();
</script>

Do you have an example where it could break down if something like
this is implemented?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jörn Zaefferer  
View profile
 More options Feb 13 2007, 2:01 pm
From: Jörn Zaefferer <Enc...@gmx.net>
Date: Tue, 13 Feb 2007 20:01:46 +0100
Local: Tues, Feb 13 2007 2:01 pm
Subject: Re: [Dev] Automatic $(document).ready
Sam Collett schrieb:
> I have seen a few times that some are not putting code in
> $(document).ready, so are sometimes asking why their code does not
> work, e.g. you may see this
> ...
> <script type="text/javascript">
> $("#mydiv").slideDown();
> </script>
> </head>
> <body>
> <div id="mydiv">...

> Would it be possible for jQuery to delay execution if no element is
> matched and the page isn't fully loaded? That way #myDiv will slide
> down as expected.

John actually had some code that did just that. But in most cases it
works around a programming error that should be fixed instead, therefore
it never got to wider public. The additional code and possible
performance lost isn't really worth it.

--
Jörn Zaefferer

http://bassistance.de


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sam Collett  
View profile
 More options Feb 13 2007, 2:08 pm
From: "Sam Collett" <sam.coll...@gmail.com>
Date: Tue, 13 Feb 2007 19:08:24 +0000
Local: Tues, Feb 13 2007 2:08 pm
Subject: Re: [Dev] Automatic $(document).ready
On 13/02/07, Jörn Zaefferer <Enc...@gmx.net> wrote:

Let me guess - was it Internet Explorer that proved to be troublesome?
Using setInterval is the only way I can think of for doing this (but
could slow down the browser if there is lots of code calling it).

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Resig  
View profile
 More options Feb 13 2007, 3:41 pm
From: "John Resig" <jere...@gmail.com>
Date: Tue, 13 Feb 2007 15:41:08 -0500
Local: Tues, Feb 13 2007 3:41 pm
Subject: Re: [Dev] Automatic $(document).ready

nope - the code that I wrote was really cool, but it wasn't completely
"perfect". For example, you could do this:

$("div").hide();

but doing this would fail:

var val = $("input").val();

Because you could only defer the chains, not 'complex' operations like
assignments.

--John

On 2/13/07, Sam Collett <sam.coll...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google