【发布时间】:2012-11-15 06:47:05
【问题描述】:
App.Views.WidgetAvailable = Backbone.View.extend({
tagName: 'li',
className: 'widget',
template: template('available_template'),
render: function(){
this.$el.html(this.template(this.model.toJSON()));
return this;
}
});
所以我得到了两个集合使用的这个视图,问题是这两种情况下只有模板属性不同。因此,我试图弄清楚如何动态设置 template: 属性。
有人知道怎么做吗?
问候,
【问题讨论】:
-
当您initialize您的视图时,尝试将其作为参数传入。