仅渲染模板包装器Backbone.Marionette.CompositeView

时间:2015-09-01 15:51:50

标签: backbone.js render marionette

我有一个带标题的模板(选择过滤器)和带有集合模型列表的部分。视图(Backbone.Marionette.CompositeView)总是在第一次加载模板包装器和模型时自动呈现。

有没有办法在第一次加载时只渲染模板包装器?

1 个答案:

答案 0 :(得分:0)

没有。但您可以即时切换模板。

initialize: function(){
    this.template = template1(); // initial render will use template 1
},
onRender: function(){
    this.template = template2(); // point to template 2 after every render. So each subsequesnt render will use template 2.
},
doStuff: function(){
    this.render(); // call render when doing stuff
}