我想暂停绑定变量点作为false
的decalaration。我尝试了几种方式,但没有工作
任何人帮助我?
这是我的代码:
$(document).on('suspendSelection', this.suspendSelection.bind(this));
$(document).on('updateSelection', this.beforeStartSelect.bind(this)); //require to suspend when i get suspend selection triggered!
我的尝试:
suspendSelection : function () {
$.unbind('updateSelection', this.beforeStartSelect.bind(this)); //not works
}
suspendSelection : function () {
this.Update.unbind('updateSelection', this.beforeStartSelect.bind(this)) //not works
},
答案 0 :(得分:1)
如果您使用on()方法在某个元素上注册了某个事件处理程序,那么您只需使用off()
删除它 $(document).on('updateSelection', this.beforeStartSelect.bind(this));
$(document).on('suspendSelection', this.suspendSelection.bind(this));
只需像这样更新你的suspendSelection(),
suspendSelection : function(){
/* select the same element, call off() passing the event to
remove and the handler function you used while registering*/
$(document).off('updateSelection', this.beforeStartSelect.bind(this));
}
希望这会有所帮助:)