阅读背景:

Backbone:将事件附加到此。$ el和重新渲染会导致绑定多个事件

来源:互联网 

I need to attach an event to the main view element, this.$el. In this case its an 'LI'. Then I need to re render this view sometimes. The problem is if i re render it, it attaches any events in the onRender method that is attached to this.$el each time its rendered. So if i call this.render() 3 times the handler gets attached 3 times. However, if i attach the event to a childNode of this.$el, this does not happen and the events seem to be automatically undelegated and added back on each render. The problem is I NEED to use the main this.$el element in this case.I need to attach an event to the main view elem




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: