Last active
August 29, 2015 14:11
-
-
Save jmcelroy5/b44d63d8d06e5bd42e5a to your computer and use it in GitHub Desktop.
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
// Creating a Backbone Model | |
var Person = Backbone.Model.extend({ | |
// default attributes | |
urlRoot:'http://gdibb.herokuapp.com/people', // Is this where the URL goes? | |
defaults: { | |
role: 'hater', | |
imgUrl: 'http://uproxx.files.wordpress.com/2012/09/grumpy-cat-03.jpg', | |
firstName: 'Grumpy', | |
lastName: 'Cat' | |
}, | |
// custom method on a Person model | |
generateUserName: function(){ | |
var username = this.get('firstName') + this.get('lastName'); | |
this.set('userName', username); | |
return username; | |
}, | |
// initialize | |
initialize: function() { | |
this.generateUserName(); | |
} | |
}); | |
// Creating a new person model | |
me = new Person({id: 123, | |
imgUrl: 'http://tinyurl.com/lagfw62', | |
firstName: 'Jessica', | |
lastName: 'McElroy'}); | |
// Getting 404 error in console when this runs | |
me.save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment