Created
August 28, 2012 07:11
-
-
Save Thibaut/3495767 to your computer and use it in GitHub Desktop.
Revisions
-
Thibaut created this gist
Aug 28, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ Include = savePrevious: -> @constructor.records[@id].previousAttributes = @attributes() revertChanges: -> if @previousAttributes attrs = {} attrs[key] = @previousAttributes[key] ? null for key in @constructor.attributes @load attrs @savePrevious() previous: (attr) -> @previousAttributes?[attr] hasChanged: (attr) -> @previous(attr) isnt @[attr] Spine.Model.Dirty = extended: -> @bind 'refresh', (records) -> record.savePrevious() for record in records @bind 'save', (record) -> record.savePrevious() @include Include