I'm using $.when
to run 2 functions prior to some other logic. Now, in several cases I need to run a different set of functions prior to doing that same logic, so I wanted to pass an array of the functions to $.when
, but couldn't make it run.
Something like:
function funcA(){
console.log("funcA");
}
function funcB(){
console.log("funcB")
}
var funcArr = [funcA, funcB];
$.when(funcArr).then(function(){
console.log("DONE!");
});
But this doesn't work and the only thing written to the console is "DONE!". I read the following How do you work with an array of jQuery Deferreds?, but the following behaves the same:
$.when.apply($, funcArr).then(function(){
console.log("DONE!")
});
What's wrong there? Thanks.