Skip to content

Instantly share code, notes, and snippets.

@starzonmyarmz
Created December 2, 2011 20:49
Show Gist options
  • Save starzonmyarmz/1424779 to your computer and use it in GitHub Desktop.
Save starzonmyarmz/1424779 to your computer and use it in GitHub Desktop.
// Views
var SchoolsView = Backbone.View.extend({
el: $('#ridley_schools table'),
collection: new SchoolList(),
matchingSchools: $('#school_row_template').html(),
initialize: function(){
_.bindAll(this, 'render'); // to solve the this issue
this.collection.bind('reset', this.render);
this.collection.fetch({
error: function() {
console.log('error fetching school data');
}
});
},
events: {
'click button.compare': 'addSchoolToCompare'
},
render: function(){
// console.log(this.collection.toJSON());
var tmpl = _.template(this.matchingSchools, { data : this.collection.toJSON() } );
$(this.el).html(tmpl);
return this;
},
addSchoolToCompare: function(){
console.log('clicked');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment