Templates 带主干的对象列表中的对象列表

Templates 带主干的对象列表中的对象列表,templates,backbone.js,Templates,Backbone.js,我的应用程序中显示了一个结构。有人知道如何显示下面的结构吗?我试过在主干内使用handlebarJS,但它对我不起作用 1) Json object has list of objects A 2) A has prop A and list of objects B 3) B has list of objects B1,B2,B3 4) each of B1,B2,B3 has 2 properties. 因此,图例标签是道具A(名称) 代码: 在我的模板中,我可以将people

我的应用程序中显示了一个结构。有人知道如何显示下面的结构吗?我试过在主干内使用handlebarJS,但它对我不起作用

 1) Json object has list of objects A 
 2) A has prop A and list of objects B
 3) B has list of objects B1,B2,B3
 4) each of B1,B2,B3 has 2 properties.
因此,图例标签是道具A(名称)

代码:

在我的模板中,我可以将people.name打印为字段集图例,但在该字段集内,我循环使用people.objects,如下所示

<fieldset> 
    <legend>{{name}}</legend>

    {{#each people.objectList}}

    <label>{{string1}}</label>

    <label>{{string2}}</label>

    {{/each}}

</fieldset> 

在集合中还有其他方法吗?

我看到的主要问题是当您尝试将数组附加到视图的el中时,PeopleListView的呈现调用:

this.collection.each(function (model) {

    var view = new PersonItemView({ model : model });

    people.push( view.render().el); 
});

this.$el.append(people);
您需要在循环中从view.render调用附加el:

this.collection.each(function (model) {

    var view = new PersonItemView({ model: model });

    this.$el.append(view.render().el);
});
或者,在附加该数组之前,需要将其转换为直接标记:

this.collection.each(function (model) {

    var view = new PersonItemView({ model: model });

    people.push(view.render().el);
});

this.$el.append(people.join(''));

什么不起作用?您尝试了什么?您是否有用于此数据的模板?如果是这样,你想使用哪个模板引擎?是的,我正在使用模板..我刚刚编辑了我的主要帖子…你现在可以看到代码了。。。
this.collection.each(function (model) {

    var view = new PersonItemView({ model : model });

    people.push( view.render().el); 
});

this.$el.append(people);
this.collection.each(function (model) {

    var view = new PersonItemView({ model: model });

    this.$el.append(view.render().el);
});
this.collection.each(function (model) {

    var view = new PersonItemView({ model: model });

    people.push(view.render().el);
});

this.$el.append(people.join(''));