Created
August 4, 2015 15:47
-
-
Save vicneanschi/66c90ef1c63fe3d8cce3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Collection save | |
Backbone.Collection.prototype.save = function (options) { | |
// create a tmp collection, with the changed models, and the url | |
var tmpCollection = new Backbone.Collection( this.changed() ); | |
tmpCollection.url = this.url; | |
// sync | |
Backbone.sync("create", tmpCollection, options); | |
}; | |
Backbone.Collection.prototype.changed = function (options) { | |
// return only the changed models. | |
return this.models.filter( function(m){ | |
return m.hasChanged() | |
}); | |
}; | |
// and sync the diffs. | |
self.userCollection.save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment