Created
February 4, 2015 06:05
-
-
Save code-for-coffee/ccaf71a7ef63328047d4 to your computer and use it in GitHub Desktop.
Backbone Enterprise Practices - Ch3 #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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