Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Last active August 29, 2015 14:16
Show Gist options
  • Save vanderhoop/f4257993c080a0783daa to your computer and use it in GitHub Desktop.
Save vanderhoop/f4257993c080a0783daa to your computer and use it in GitHub Desktop.

Backbone Model Rep

You just learned the magical AJAX-y ease of working with a Backbone model. Now it's your turn to implement a backbone model that you can persist.

Directions

  1. Use Backbone.Model.extend() to create a new constructor function called FootSoldier.
  • Note: there are a number of FootSoldier's in the database. For now, let's assume we're only interested in the FootSoldier with id of 1.
  1. Using your new constructor function, instantiate the FootSoldier.
  2. Use Backbone's convenient .fetch() to retrieve the FootSoldier's data via ajax.
  3. Examine the foot soldier's image_url and height_in_inches attributes using .get()
  4. Change the foot soldier's image_url to a strange photo you find on the internet.
  5. Use Backbone to persist the changes to the database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment