How can I run something after the completion of $ (document) .ready ()?

Is there a way for your function to be called as LAST in the queue, $(document).ready()or is there a way to raise an event after completion?

I want to essentially see if something was fired $(document).ready(), and if not, start it after the wards. If I put this code in a finished document, then there is no guarantee that it will be executed last, so several checks may occur.

+3
source share
3 answers

Add another block $(document).ready()to the end of your code. jQuery executes them in the order in which it sees them, so if you put another block at the end of the code, it should be called after the other completes.

+4

, :

.

function myFunc()
{
    if (myFuncHasFired)
        return;
    myFuncHasFired = true;
    //your func code here
}

, , , , .

+5

This sounds like the perfect use case for the readyX plugin: http://plugins.jquery.com/project/readyx

The plugin provides a queue for ready events that should happen last.

0
source

All Articles