My jQuery function is ready to shoot too soon ... It is not ready!

I am adding resizable to several div tags that are part of a complex page. But $ (document) .ready () if executed too early. Not everything was analyzed, and resizing failed.

How do I make jQuery really wait until the document is ready?

I tried...

$(document).ready() $(document).load() $(window).load() 

Adding a temporary button with the same code as me, after clicking the page, I get the correct resizable interface.

I am using jQuery v1.4.2 and jQuery UI v1.8.4 with Firefox v3.6.8.

+4
source share
3 answers

The stupid must offend.

I also had an onload event for the body that was fired after jQuery events, but depending on size.

Answer. Do not use both methods.

+1
source

But $ (document) .ready () if executed too early. Not everything was analyzed, and resizing failed.

It should not be. ready() fires when parsing and visualizing the DOM. The only things that can still be downloaded are style sheets (I don’t know what to do with them) and images.

If your size depends on the uploaded images, use load .

+1
source

Try using $(window).load() rather than $(document).ready() ... This will wait until EVERY single aspect is loaded before completion ... a little slower, but should smooth out your error

0
source

All Articles