如何取消绑定默认视图事件绑定?
问题描述:
我有一个由Backbone Marionette项目视图呈现的集合。只要收藏重置,视图就会重新渲染。据我所知,这是默认的Backbone.Marionette行为。有没有一种方法可以禁用它?如何取消绑定默认视图事件绑定?
var ActiveWordView = M.ItemView.extend({
template: '#active-word-template',
tagName: 'form',
onRender: function() {
// This is being triggered when the collection resets, even
// though I didn't specify that behaviour in an initializer.
console.log("Active word re-rendered");
}
});
var activeWordView = new ActiveWordView({
collection: this.model.get('words'),
});
this.activeWordRegion.show(activeWordView);
答
重写initialEvents
方法。
var ActiveWordView = M.ItemView.extend({
template: '#active-word-template',
tagName: 'form',
initialEvents: function() {},
});
我刚刚在我的答案打“post”时,当这件事通过。正是我要说的:) – 2012-07-24 15:14:56
正如我完成键入的问题,我想“我应该看看来源”。 2分钟后找到答案,明确为天。 – 2012-07-24 15:45:24