Reset model attributes when textbook editing is cancelled

This commit is contained in:
David Baumgold
2013-06-25 16:35:51 -04:00
parent 9797b34c4e
commit 74b9703def
2 changed files with 12 additions and 0 deletions

View File

@@ -13,6 +13,16 @@ CMS.Models.Textbook = Backbone.AssociatedModel.extend({
relatedModel: "CMS.Models.Chapter",
collectionType: "CMS.Collections.ChapterSet"
}],
initialize: function() {
this.setOriginalAttributes();
return this;
},
setOriginalAttributes: function() {
this._originalAttributes = this.parse(this.toJSON());
},
reset: function() {
this.set(this._originalAttributes);
},
isEmpty: function() {
return !this.get('name') && this.get('chapters').isEmpty();
},