I having some trouble figuring this problem out where I have one button which does a mass clicking of other buttons on a page. Though the issue is I don’t want to activate all the buttons all at once and basically time them out until the other buttons finish their actions.
Page.MassCheckStats = function(){
$('[data-field="button_update_stats"]').each(function(){
$(this).click();
});
}
How can I get the above code to click 3 buttons at a time before going on to the other buttons.
You can use recursive timeouts like this:
(sorry, i forgot it was three buttons at a time);
where 1000 = 1000 miliseconds = 1 second
and here’s the fiddle for it:
http://jsfiddle.net/andrepadez/cR4tP/2/
the firs line inside the function is a trenary operator. it means that if you do not pass any parameter calling the function (the first time it is called),
typeof button == 'undefined', so it will assign tovar buttonthe first element selected by the jQuery selector –$('[data-field="button_update_stats"]')[0]. When i call it again from the timeouts, i am passing the current$(button).next()so it will assume what was passed in the parameter.