Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created September 26, 2011 23:24
Show Gist options
  • Save juliocesar/1243745 to your computer and use it in GitHub Desktop.
Save juliocesar/1243745 to your computer and use it in GitHub Desktop.
Set collection to saved/unsaved on change
var CookieCollection = Backbone.Collection.extend({
saved : false,
model : Cookie,
initialize: function() {
this.bind('add', this.setUnsaved, this);
this.bind('remove', this.setUnsaved, this);
},
setUnsaved: function() {
this.saved = false
}
});
var cookies = new CookieCollection;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment