Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I have a javascript script running in one of my webpages. In this script I have 8 functions running one after another, in order.

My question is, is there a way of looping this queue of functions, so that is constantly runs, in the same order that it first runs?

Any replies are most appreciated,
Tom.
Posted
Updated 22-Feb-12 2:57am
v2

Why don't you call the next function on the last line of code in the 'current' function?

var myFunctions = {
    one: function(){
        myFunctions.two();
    },
    two: function(){
        myFunctions.three();
    },
    three: function(){
        myFunctions.four();
    },
    four: function(){
        myFunctions.one();
    }
}

$(document).ready(function(){ myFunctions.one(); });


But than ofcourse with eight functions in stead of four.

Good luck!
 
Share this answer
 
hi,

Here[^] is a contribution to Eduard's answer...

Another solution is to make an array of your functions and the use jquery each and setTimeout to call them one by one...
 
Share this answer
 
Thankyou Eduard and Martin both your solutions work fine!

Tom.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900