Skip to content

Instantly share code, notes, and snippets.

@jookyboi
Created July 10, 2013 00:21
Show Gist options
  • Save jookyboi/5962501 to your computer and use it in GitHub Desktop.
Save jookyboi/5962501 to your computer and use it in GitHub Desktop.
var MyModel = Backbone.Model.extend({
initialize: function (options) {
// These attributes need to be stored in a different format
// Dates
this.startYear = new Date(options.startTime).getFullYear();
// Rounding numbers
this.wholeNumber = Math.Round(options.numberWithDecimals);
// Storing empty strings as nulls
if (options.fullName == null || options.fullName == "") {
this.fullName == null;
} else {
this.fullName = options.fullName;
}
// These are fine as they are
this.fieldA = options.fieldA;
this.fieldB = options.fieldB;
this.fieldC = options.fieldC;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment