简而言之,我想对其他收藏和模型进行深度收集
结构是这样的
[{
mainCategory: "Something"
subCategories: [
{
category: "SomethgingElse",
labs: [
{
id: 1,
title: "Title",
description : "Lorem ipsum dolor sit amet"
availablelanguages: ["fr","en"]
},
{
id: 2,
title: "Another Title",
description : "Lorem ipsum dolor sit amet",
availablelanguages: ["fr","en"]
}]
},
{
category: "Testing",
labs: [
{
id: 1,
title: "ZZZZ",
description : "Lorem ipsum dolor sit amet"
availablelanguages: ["ar","en"]
},
{
id: 2,
title: "VVVVV",
description : "Lorem ipsum dolor sit amet",
availablelanguages: ["ar","en"]
}]
}
]
}]
我定义了一些集合和模型,如下所示
var Item = Backbone.Model.extend({
defaults: {
title : '',
description: '',
availableLangagues : []
}
});
var Items = Backbone.Collection.extend({
model: Item
});
var Category = Backbone.Model.extend({
defaults: {
categoryName: '',
labsList: new Items()
}
});
var Categories = Backbone.Collection.extend({
model: Category
});
var TopCategory = Backbone.Model.extend({
defaults: {
topCategory: "",
categories: new Categories()
}
});
var TopCategories = Backbone.Collection.extend({
model: TopCategory
});
fetch
我的问题在这里我想调用TopicCategories
我想填充所有内容,fetch
它将返回JSON
示例中传递的类似,但如果我调用它将返回数据,但数组将只是普通的 JavaScript 数组,而不是像我这样的骨干fetch
集合TopCategories
在默认值中通缉