2012-07-24 71 views
0

我有一個由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); 

回答

4

重寫initialEvents方法。

var ActiveWordView = M.ItemView.extend({ 
    template: '#active-word-template', 
    tagName: 'form', 

    initialEvents: function() {}, 
}); 
+0

我剛剛在我的答案打「post」時,當這件事通過。正是我要說的:) – 2012-07-24 15:14:56

+0

正如我完成鍵入的問題,我想「我應該看看來源」。 2分鐘後找到答案,明確爲天。 – 2012-07-24 15:45:24