5 ms·
So given: window.Post = Backbone.Model.extend({...}); window.Comments = Backbone.Collection.extend({...}); var p = new Post( id: 3, te
by raganwald 16y ago
So given:
window.Post = Backbone.Model.extend({...});
window.Comments = Backbone.Collection.extend({...});
var p = new Post(
id: 3,
text: 'test',
comments: [
{ cid:4, bleh:5},
{c id:6, bleh:4}
]
});
You want some way to declare that comments are Comments, so that it is always the case that:
(p.attributes.comments instanceof Comments) === true
And you also want:
p.attributes.comments.add({...});
To trigger a 'change:comments' event on p, even though you aren't changing the reference to the comments collection, just changing its comments.
Do I understand you correctly?
- elliottkember 16y agoI've found myself wanting this, too - I sometimes get confused as to which features I can use between models and collections.i
- d0m 16y agoYes, perfectly.
- raganwald 16y agohttps://github.com/unspace/faux/issues#issue/33 https://github.com/unspace/faux/issues#issue/33