Skip to content

Instantly share code, notes, and snippets.

View timc3's full-sized avatar

Tim Child timc3

View GitHub Profile
@timc3
timc3 / nesting.js
Created February 12, 2013 10:31 — forked from geddski/nesting.js
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];