$(document).ready( function() {} ) and $( function() {} ) are the same
thing. The latter is just a shortcut to the former. If one is acting oddly,
chances are that the other will too.

Richard, $( function() {} ) should *never* call your function more than
once. It definitely shouldn't call it whenever the DOM changes. That's not
how it works at all. If that is happening, something must be very wrong in
your page, and I wouldn't trust any JavaScript code to run correctly. I
certainly wouldn't use $(window).load() as a workaround.

If you can post a link to a test page that demonstrates the problem, we
could take a look at it and find out what's wrong.

-Mike

On Wed, Dec 16, 2009 at 6:19 AM, Juan Ignacio Borda <
juanignaciobo...@gmail.com> wrote:

>  try using:
> $(document).ready(function(){
>
>  ...your code here
>
> });
>
> this is the JQuery way
>
>
> -------- Original Message --------
>
> Those events window.onload, in jQuery, that would be $(window).load
> (...), should *not* be firing at any time other than when the document
> loads the first time... something else has to be going on with your
> code to fire off that code again
>
> On Dec 15, 3:27 pm, Richard KLINDA <rkli...@gmail.com> <rkli...@gmail.com> 
> wrote:
>
>
>  Hello, what is a good way to run a code snippet after the page is
> loaded, but only just one time?
>
> I use the ready event $(function(){...}); most of the time, but
> sometimes it fires multiple times (when the DOM changes I think), and
> rarely there are stuff that I only want to run JUST ONCE per pageload.
>
> What is a good way to achieve that?
>
> Now I do window.onload = function() {...}, but I hope there is something
> better.
>
> Thanks in advance...
>
> --
> Richard
>
>
>
>
>

Reply via email to