If I have a backbone collection that has a method that calls an asynchronous method on each of its models like this:
getStatus: function() {
this.each(function(model) {
model.getStatus();
});
}
And in the model class, an asynchronous ajax call is made like this:
getStatus: function() {
$.ajax({
//ajax properties here
});
}
How can I determine when each and every model has completed it's asynchronous call (not necessarily successfully) and returned?
So in my collection, I need a getStatusSuccess
method that executes after all these asynchronous calls have been completed. I have looked into jQuery deferreds, and I have tried a few things to get it to work, but to no avail. However, I still believe that it can be solved using deferreds.