snoj/knockup

Collections in models within collections...doesn't work

snoj opened this issue · 0 comments

snoj commented

You can only go so deep.

//test4
kidModel = ku.Model.extend();
kidModelCollection = ku.Collection.extend({
  model: kidModel
});
familyModel = ku.Model.extend();
familyModelCollection = ku.Collection.extend({
  model: familyModel
})
test4model = new ku.Model({
  c: new familyModelCollection()
});
test4model.get('c').add(new familyModel());
t40k = new kidModelCollection([{name: "jet"}, {name: "jo"}]);
test4model.get('c').at(0).set({'kids': t40k});
console.log(JSON.stringify(test4model.get('c').at(0).get('kids'), null, " "))
console.log(JSON.stringify(ko.mapping.toJS(test4model._ku().c()[0].kids), null, " "));

output

[
  {
    "name": "jet",
    "id": "c14"
  },
  {
    "name": "jo",
    "id": "c15"
  }
]

[
  {},
  {}
]