Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created May 19, 2013 04:36
Show Gist options
  • Save marti1125/5606707 to your computer and use it in GitHub Desktop.
Save marti1125/5606707 to your computer and use it in GitHub Desktop.
Backbone 02 codeschool
var Appointment = Backbone.Model.extend({
defaults: function (){
return {
title: 'Checkup',
date: new Date()
}
}
});
var Appointment = Backbone.Model.extend({urlRoot: '/appointments'});
var appointment = new Appointment({id:1})
appointment.fetch();
appointment.set({cancelled: true})
appointment.save();
appointment.on('change:cancelled', function(){
alert("Hey Dr. Goodparts, your appointment has changed!");
});
console.log(appointment.toJSON()); //get all data into json format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment