Without really knowing what .center() does, I'd assume it's because when
$(document).ready() fires, the image isn't loaded.  I suspect the 1
second delay gives it enough time to do so.

Does the image have a set width and height?  If you specify those, it
might work.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Truppe Steven
Sent: Monday, October 23, 2006 5:03 PM
To: jQuery Discussion.
Subject: [jQuery] Why do i need a delay in $(document).ready when using
the center plugin ?

Hello again,

i'm using the center plugin to center images inside a div. But i have to
call it with a timeout like this:

$(document).ready(function(){
   setTimeout("doCenter()",1000);
});

function doCenter(){
    $(".jqcenter").each(){
       $(this).center();
    }
}


I do not really understand why i need a timeout here because DOM should
allready be ready inside of $(document).ready().

The Problem with this is that it fails for some reason in certain cases,
so that the image is misplaced. To me it looks like that in these cases
the function is called to early because if i refresh the page it look
fine.

If i replace setTimeOut and call the function direct with doCenter() it
does not work at all.
Do i have a general understanding problem or what am i doing wrong ?

best regards,
Truppe Steven

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to