如何通过“触发”事件解除绑定

How to unbind by `trigger` event

我想暂停绑定一个变量点作为声明 false。我尝试了几种方法,但没有用

有人帮帮我吗?

这是我的代码:

$(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
        },

如果您使用 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));
}

希望这对您有所帮助:)