Skip to content

Instantly share code, notes, and snippets.

@davemo
Last active December 18, 2015 00:59
Show Gist options
  • Save davemo/5700294 to your computer and use it in GitHub Desktop.
Save davemo/5700294 to your computer and use it in GitHub Desktop.
DataTable = Backbone.View.extend({
initialize: function() {
this.collection.on("reset", this.renderTable);
},
renderTable: function() {
this.collection.each(function(data) {
this.$("tbody").append("<tr><td>" + data.fieldOne "</td></tr>");
}, this);
}
});
var table = new DataTable({ collection: someCollection, el: "#some-container" });
someCollection.fetch(); // triggers the reset when completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment