i'm trying to create a Tree with backbone.js models, but i'm having a problem with it:
Collection: MCollection:
define
(
['backbone', 'models/M'],
function(Backbone, M)
{
'use strict';
return Backbone.Collection.extend
(
{
model: M,
}
}
);
}
);
and the model that has a collection that depends on that model...
Model: M
define
(
['backbone', 'underscore', 'vent', 'collections/MCollection'],
function(Backbone, _, vent, MCollection)
{
'use strict';
return Backbone.Model.extend
(
{
_children : null,
initialize : function(attributes, options)
{
this._children = new MCollection();
},
}
);
}
);
so what is happening.. I load the model M, but in the model i'm also creating a collection which has as model: M, so it depends on each other.. as a result the model of MCollection remains undefined, while it should be referrering to M.
I tried thinking how i can fix this but i can't find a way to do this.. Do you?