.wait(events ,callback)
Description:
Wait for a specified event on any of the selected elements before continuing method invocation.
- events –
string
- A string containing one or more event types, such as "click" or "submit" or custom event names.
- callback –
function(count…)
, optional - a method that is called once just before continuing the invocation chain.
- All current iteration counts/events (from inner-most to outer-most loop) are passed as arguments.
Examples with waiting for an event
Example #15: enable continue button only after making choices
In this example the continue button should get enabled only if for each choice the user has selected some value.
The used parallel .each()..all() loop waits for each line until some radio input is selected. Any order of making choices is allowed.
⇒Example #19: pause animation cycle on mouseover
There is a animation cycle rotating three images. Once you move the mouse cursor over it, it pauses until the mouse is moved away.
A little helper function checks whether the mouse is over the image. If that's the case a deferred jQuery object waiting for the mouseleave event is returned.The running loop can be written in a single jQuery line.
⇒