且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Backbone.js视图中触发/绑定自定义事件?

更新时间:2022-12-11 17:29:52

您的onScrollEnd事件绑定到视图的顶部元素; scrollEnd将当视图的HTML元素接收到onScrollEnd事件时调用。

Your onScrollEnd event is bound to the view's top element; scrollEnd will be called when the view's HTML element received an onScrollEnd event.

但是您触发了View对象上的onScrollend事件而不是元素。

But you are triggering an onScrollend event on your View object, not the element.

所以你可能想说 $(self.el).trigger('onScrollEnd'); ,或者直接调用函数: self.scrollEnd()

So you probably want to say $(self.el).trigger('onScrollEnd'); instead, or perhaps call the function directly: self.scrollEnd().