Created
January 25, 2017 08:35
-
-
Save martsie/ab1b052cf5466ff3c384b9a4f0a3a24c to your computer and use it in GitHub Desktop.
Backbone model in CoffeeScript with default values
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 characters
# 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