【发布时间】:2015-06-18 06:51:18
【问题描述】:
我正在使用 Marionette 的复合视图显示一个表格视图。复合视图的模板有一个 tbody,其首字母显示加载动画 gif。
现在,当调用渲染方法时,我想删除这个初始行,然后附加集合获取的结果。然而,Marionette 的默认渲染实现似乎附加到了 tbody。
我的项目视图的项目模板:
<td><input type="checkbox" class="checkboxContact" id="<%-id %>"/></td>
<td><%-name %></td>
<td> <%-msisdn %></td>
<td> <%-email %></td>
<!--
<td> <%-address %></td>
<td> <%-last_modified_time %></td>-->
<td>
<i rel="tooltip" class="fa fa-pencil-square-o actions" id="editIcon" title="edit"></i>
<i rel="tooltip" class="fa fa-trash-o actions" title="delete"></i>
</td>
重写的渲染方法,如下。
render: function() {
if (this.collection.size() <= 0) return;
this.$el.html(this.template((this.collection.toJSON()));
return this;
}
我也试过
render: function() {
if (this.collection.size() <= 0) return;
this.$el.html(this.template({
collection: this.collection.toJSON()
}));
return this;
}
这些都不起作用。
【问题讨论】: