【问题标题】:Render footer on marionette composite view在 Marionette 复合视图上渲染页脚
【发布时间】:2013-09-05 21:04:35
【问题描述】:

我目前有一个呈现模型表的复合视图。我在复合视图模板中有thead,每个模型都是使用 itemViewTemplate 呈现的。

我想做的是在模型之后渲染一个 tfoot,复合视图可以这样做吗?我会绑定到 onrender 并将另一个模板附加到复合视图的末尾吗?

【问题讨论】:

  • 您需要为tfoot 使用您的任何模型/集合数据吗?
  • 为什么不在页脚上方的区域中有一个包含您的CompositeView 的Layout?
  • 威尔,是的,我需要使用一些收集数据。将在下面尝试克里斯的答案

标签: backbone.js marionette


【解决方案1】:

绝对的。

var Row = Backbone.Marionette.ItemView;

var Table = Backbone.Marionette.CompositeView.extend({
    template: /* resolves to: */ '<table><thead> {{header row}} </thead>' +
                                 '<tbody></tbody>' +
                                 '<tfoot> {{footer row}} </tfoot>',
    itemView: Row,
    itemViewContainer: 'tbody'
});

【讨论】:

  • 谢谢克里斯,我在文档中完全错过了这个! itemViewContainer 是我所缺少的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多