Created
March 9, 2012 16:03
Revisions
-
Takazudo revised this gist
Mar 9, 2012 . 1 changed file with 1 addition and 1 deletion.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 @@ -19,7 +19,7 @@ or var MyModel = Backbone.Model.extend({ set: function() { Backbone.Model.prototype.set.apply(this, arguments); this.updateDate(); }, updateDate: function(){ var date = this.get('date'); -
Takazudo revised this gist
Mar 9, 2012 . 1 changed file with 1 addition and 1 deletion.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 @@ -19,7 +19,7 @@ or var MyModel = Backbone.Model.extend({ set: function() { Backbone.Model.prototype.set.apply(this, arguments); self.updateDate(); }, updateDate: function(){ var date = this.get('date'); -
Takazudo created this gist
Mar 9, 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,30 @@ var MyModel = Backbone.Model.extend({ initialize: (attrs){ var self = this; self.updateDate(); self.bind('change:date', function(){ self.updateDate(); }); }, updateDate: function(){ var date = this.get('date'); if(_.isString(date)){ this.set('date', new Date(date)); } } }); or var MyModel = Backbone.Model.extend({ set: function() { Backbone.Model.prototype.set.apply(this, arguments); updateDate(); }, updateDate: function(){ var date = this.get('date'); if(_.isString(date)){ this.set('date', new Date(date)); } } });