.until(bool ,loopContext)

Description: The end for a repeat loop that finishes if the boolean parameter is true.

bool – boolean
whether to stop the loop or not.
If false then the loop runs infinitely.
loopContext – boolean, optional
if true then the current jQuery context starts the next loop iteration. Otherwise the original context from the .repeat() call is used for each iteration.
Defaults to false.

Usage pattern

$('.some').repeat(interval).doThis().until(false);
$('.some').repeat(interval,true).doThis().until(false);

Examples with boolean loop end condition

Example #12: cyclic button clicks

The buttons can be clicked one after the other. At the end the cycle starts over and over.

Remark that the code is the same no matter how many buttons we have.

$('.example button').repeat().each($)
   .attr('disabled',false).one('click')
   .attr('disabled',true).until(false);


Example #14: wait a timeout after each click before blinking

With the concatenation of two .wait()s we achieve a single short blink.

Instead of attaching an event handler explicitly we start an infinite event loop for the "click" event. Repeat loops are always sequential, i.e. the next iteration can start only if the previous one ended. You can see this behavior when double- or triple-clicking the button.

$('.example button').repeat('click').prev()
   .wait(500).addClass('blink')
   .wait(300).removeClass('blink');

That text blinks half a second after hitting .