[英]Event Binding in Backbone.Marionette context
我想知道為什么_.bindAll(this, ['onSortRemove']);
在以下代碼(1)中出現以下錯誤:
未捕獲的TypeError:對象[對象窗口]沒有方法'resetItemViewContainer'
為了使工作正常,我需要實現以下代碼_.bindAll(this);
。
我的問題是:應該_.bindAll(this, ['onSortRemove']);
足夠? 如果沒有,為什么?
(1)
initialize: function () {
_.bindAll(this, ['onSortRemove']); // it does not work
_.bindAll(this); // it works
}
onSortRemove: function () {
setTimeout(this.render, 0);
}
語法錯誤
initialize: function () {
_.bindAll(this, 'onSortRemove'); // <- no array wrapper
}
文檔的[*methodnames]
的語法並不是說“將它包裝在一個數組中”。 這是老式的文檔樣式,說“方法名稱是可選的,它可以是零個或多個參數,以逗號分隔”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.