我想绑定checkScroll()
到视图PhotoListView
,以便我可以this.checkScroll()
从内部调用,$(Window).scroll()
而无需先var self = this
调用self.checkScroll()
.
问题:但是绑定似乎不起作用,并且我收到错误Uncaught TypeError: Object [object Window] has no method 'checkScroll'
我绑定错误了吗?
看法
PhotoListView = Backbone.View.extend({
el: '#photo_list',
initialize: function() {
_.bindAll(this, 'checkScroll');
this.bind('checkScroll', this)
$(window).scroll(function() {
this.checkScroll();
});
},
checkScroll: function() {
console.log('checkScroll');
}
});