admin管理员组文章数量:1403480
Is there a way to have your function be called as the LAST in the $(document).ready()
queue or, is there a way to trigger an event once this has pleted?
I want to essentially see if something was fired by $(document).ready()
and, if not, fire it after wards. If I put this code into document ready then there is no guarantee it will execute last so could result in multiple checks.
Is there a way to have your function be called as the LAST in the $(document).ready()
queue or, is there a way to trigger an event once this has pleted?
I want to essentially see if something was fired by $(document).ready()
and, if not, fire it after wards. If I put this code into document ready then there is no guarantee it will execute last so could result in multiple checks.
3 Answers
Reset to default 5You can set a global variable when your function is fired, and check that before running it again:
E.g.,
function myFunc()
{
if (myFuncHasFired)
return;
myFuncHasFired = true;
//your func code here
}
This does not guarantee your function will run last, but satisfies what I think is your real requirement that the function not run multiple times in one request.
Add another $(document).ready()
block to the end of your code. jQuery executes them in the order it sees them, so if you put another block at the end of the code, it should be called after the other finishes.
This sounds like the perfect use case for the readyX plugin: http://plugins.jquery./project/readyx
The plugin provides a queue for ready events that should happen last.
本文标签: javascriptHow can I fire something after (document)ready() completesStack Overflow
版权声明:本文标题:javascript - How can I fire something after $(document).ready() completes? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744401451a2604484.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论