我正在學習Backbone,我正試圖弄清楚我正在使用哪個函數庫的'on'函數。我認爲這是jQuery,但如果是這樣,我不理解API。有人可以解釋'開'功能或將我鏈接到一些文檔。第一個參數是事件。第二個參數是被調用的函數。最後的'這個'是指什麼(我假設調用類),爲什麼它需要?這裏是我的代碼直接從阿迪·奧斯馬尼,這是APPVIEW:Backbone.js on(),最後這是指什麼?
initialize : function() {
this.input = this.$('#new-todo');
this.allCheckbox = this.$('#toggle-all')[0];
this.$footer = this.$('#footer');
this.$main = this.$('#main');
window.app.Todos.on('add', this.addOne, this);
window.app.Todos.on('reset', this.addAll, this);
window.app.Todos.on('change:completed', this.filterOne, this);
window.app.Todos.on("filter", this.filterAll, this);
window.app.Todos.on('all', this.render, this);
app.Todos.fetch();
},
,如果你指的是window.app.Todos.on(「所有」 ,this.render,this); - 它會觸發Todos系列的任何變化。 (添加,重置,更改等) – nxtwrld