Skip to content

Instantly share code, notes, and snippets.

@code-for-coffee
Created February 4, 2015 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-for-coffee/ccaf71a7ef63328047d4 to your computer and use it in GitHub Desktop.
Save code-for-coffee/ccaf71a7ef63328047d4 to your computer and use it in GitHub Desktop.
Backbone Enterprise Practices - Ch3 #2
// individual row
App.Models.TableRow = Backbone.Model.extend({
referenceSelf: function() {
return this;
},
initialize: function() {
var self = this.referenceSelf(),
columns = new Array() || [];
self.set("columns", columns);
},
addColumn: function(data) {
var self = this.referenceSelf(),
columns = self.get("columns");
self.set("columns", columns.push(data));
}
});
// collection of rows
App.Collections.Table = Backbone.Collection.extend({
model: App.Models.TableRow
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment