Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created October 31, 2012 19:02
Show Gist options
  • Select an option

  • Save jcuffe/3989141 to your computer and use it in GitHub Desktop.

Select an option

Save jcuffe/3989141 to your computer and use it in GitHub Desktop.
define([
'jquery', 'underscore', 'backbone',
'collections/passengers/collection',
'text!templates/passenger/list.html'
], function ($, _, Backbone, Passengers, passengerTemplate) {
PassengerView = Backbone.View.extend({
el: $('#passengers'),
initialize: function () {
var self = this;
this.collection = new Passengers();
this.collection.add();
this.collection.each(function (passenger) {
passenger.bind('change', self.render, self);
});
},
render: function() {
console.log('render triggered');
this.$el.html(_.template(passengerTemplate, {
passengers: this.collection
}));
}
});
return PassengerView;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment