Skip to content

Instantly share code, notes, and snippets.

@martsie
Created January 25, 2017 08:35
Show Gist options
  • Save martsie/ab1b052cf5466ff3c384b9a4f0a3a24c to your computer and use it in GitHub Desktop.
Save martsie/ab1b052cf5466ff3c384b9a4f0a3a24c to your computer and use it in GitHub Desktop.
Backbone model in CoffeeScript with default values
# Define the model.
class Comment extends Backbone.Model
defaults:
name: 'test'
email: '[email protected]'
body: 'BODY'
# Create a new instance of the model.
comment = new Comment
name: 'Overriden name'
email: '[email protected]'
body: 'Overriden body value'
# Access a variable.
console.log comment.get name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment