问题
使用Backbone.Marrionette.Layout呈现一些表格数据。表格的<tbody>
一部分是Backbone.Marionette.Region,用于显示Backbone.Marionette.CollectionView。
我无法弄清楚如何使用 Marionette 的“区域”来做到这一点,而不会通过在元素内插入一个额外的 HTML 元素来弄乱表格显示<tbody>
。
示例代码
Layout
看起来像这样:
Backbone.Marionette.Layout.extend({
template:...
regions:{
list_region: '#list-region'
}
onRender:function(){
var collection = new TheCollection()
var collectionView = new TheCollectionView({
collection: collection
})
// PROBLEM: The region seems to needs its own HTML element,
// and the CollectionView also seems to need its on HTML
// element, but as far as I can see, there is only room
// for one element: <tbody>?
this.list_region.show(collectionView);
});
布局的模板包含整个表格:
<table>
<tbody id='list-region'>
</tbody>
<tfoot id='footer-region'>
Some other stuff goes here that is not a collection, so I was able
to make the View's 'tagName' property 'tr', which worked fine.
</tfoot>
</table>
有什么建议么?