Passing 'this' and argument to addEventListener function without using bind

后端 未结 4 1791
独厮守ぢ
独厮守ぢ 2021-01-03 05:18

Subsequent to removeEventListener in bootstrapped addon not working when addon disabled, I am exploring other possibilities.

Beside using bind() and cac

4条回答
  •  别那么骄傲
    2021-01-03 05:40

    http://2ality.com/2013/06/auto-binding.html

    var listener = myWidget.handleClick.bind(myWidget);
    domElement.addEventListener('click', listener);
    ...
    domElement.removeEventListener(listener);
    

提交回复
热议问题