Created
August 22, 2012 02:11
-
-
Save mxriverlynn/3421478 to your computer and use it in GitHub Desktop.
defaults
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
// backbone's `defaults` can be a function. | |
// | |
// if you need the default value to be evaluated | |
// every time you instantiate a new model, then | |
// it should be a function, not an object literal. | |
// | |
// object literals are only evaluated once, when the | |
// object is defined. | |
w.model = Backbone.Model.extend({ | |
defaults : function() { | |
return { | |
timestamp : moment().format('M/D/YYYY h:mm:ss') | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment