Skip to content

Instantly share code, notes, and snippets.

@adamfortuna
Created September 18, 2012 14:00
Show Gist options
  • Save adamfortuna/3743279 to your computer and use it in GitHub Desktop.
Save adamfortuna/3743279 to your computer and use it in GitHub Desktop.
Backbone course answer
var AppRouter = new (Backbone.Router.extend({
routes: { "appointments/:id": "show", "": "index" },
initialize: function(options){
this.appointmentList = new AppointmentList();
},
start: function(){
Backbone.history.start({pushState: true});
},
index: function(){
var appointmentsView = new AppointmentListView({collection: this.appointmentList});
appointmentsView.render();
$('#app').html(appointmentsView.el);
this.appointmentList.fetch();
},
show: function(id){
var appointment = new Appointment({id: id});
var appointmentView = new AppointmentView({model: appointment});
appointmentView.render();
$('#app').html(appointmentView.el);
appointment.fetch();
}
}));
$(function(){ AppRouter.start() });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment