English 中文(简体)
My jQuery ready function is firing too early... It s not ready!
原标题:

I m adding resizable to several div tags that are part of a complex page. But the $(document).ready() if executing too early. Not everything has been parsed and the resizable fails.

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

I ve tried...

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

By adding a temporary button with the same code as these, that I click after the page is rendered, I get the proper resizable UI.

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

最佳回答

Stupid should hurt.

I also had a body onload event that was executing after the jQuery events but on which the resizable was dependent.

Answer: Don t use both methods.

问题回答

But the $(document).ready() if executing too early. Not everything has been parsed and the resizable fails.

This shouldn t be. ready() fires when the DOM has been parsed and rendered. The only thing that could still be loading is style sheets (don t know what to do about those) and images.

If your resizable depends on images being fully loaded, use the load event instead.

Try using $(window).load() rather than $(document).ready()... This will wait until EVERY single aspect has loaded to completion... a little slower but should iron out your bug





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签