return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - How can I fire something after $(document).ready() completes? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I fire something after $(document).ready() completes? - Stack Overflow

programmeradmin2浏览0评论

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.

Share Improve this question asked May 13, 2011 at 15:28 ChrisChris 27.4k49 gold badges206 silver badges357 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

You 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.

发布评论

评论列表(0)

  1. 暂无评论