Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Created August 22, 2012 02:11
Show Gist options
  • Save mxriverlynn/3421478 to your computer and use it in GitHub Desktop.
Save mxriverlynn/3421478 to your computer and use it in GitHub Desktop.
defaults
// 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