as Eli pointed out, $.when() accepts a comma separated list of arguments and not an array. using Function.apply()
to pass in the array seems to do the trick.
function saveAll(callback) { var dataArray = [], deferreds = []; $.each(dataArray, function() { deferreds.push( save() ); }); $.when.apply(window, deferreds).then(callback); }
Read full article from ajax - raising jquery deferred.then() once all deferred objects have been resolved - Stack Overflow
No comments:
Post a Comment