Deferreds
jquery.model.deferredsModels (and views) work with jQuery.Deferred. If you properly fill out a model's [jquery.model.services service API], asynchronous requests done via the model will return a jQuery.Deferred.
Models (and views) work with jQuery.Deferred. If you properly fill out a model's [jquery.model.services service API], asynchronous requests done via the model will return a jQuery.Deferred.
findAll example
The following example, requests tasks and people and waits for both requests to be complete before alerting the user:
Note taskResponse[0] is an Array of tasks.
save and destroy example
Calls to [jQuery.Model.prototype.save save] and [jQuery.Model.prototype.destroy] also return a deferred. The deferred is resolved to the newly created, destroyed, or updated model instance.
The following creates a task, updates it, and destroys it: