下面是描述嵌套树模型的代码,以及 json 中的示例数据。如何blocks
使用提供重置data
?
var Block, Blocks, data, blocks;
Block = Backbone.Model.extend({
initialize: function() {
this.blocks = new Blocks;
}
});
Blocks = Backbone.Collection.extend({
model: Block
});
data = [
{
id: 1,
blocks: [
{id: 2, blocks: [{id: 3}]}, {id: 4}
]
},
{
id: 5
}
];
blocks = new Blocks;