viewInstance.undelegateEvents()
是否与 jQuery 的 $(this.el).unbind()
相同?
它们的功能是否与从 View 中删除事件的方式相同?
最佳答案
来自 http://backbonejs.org/docs/backbone.html#section-131
undelegateEvents: function() {
this.$el.unbind('.delegateEvents' + this.cid);
},
因此,它们几乎完全相同。但是 undelegateEvents
方法将取消委托(delegate)的范围限定为 Backbone View 使用 delegateEvents
方法明确设置的事件,使用声明性的 events
配置 View 。
关于javascript - viewInstance.undelegateEvents() 和 $(this.el).unbind() 一样吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9623921/