Skip to content

Instantly share code, notes, and snippets.

@julianitor
julianitor / backbone-save-all.js
Created July 17, 2015 07:25
Save all models of a Backbone collection if they changed.
Backbone.Collection.prototype.saveAll = function(options) {
return $.when.apply($, _.map(this.models, function(m) {
return m.hasChanged() ? m.save(null, options).then(_.identity) : m;
}));
};