Closed lifengbo closed 8 years ago
The problem with your code is, that method bind()
creates a new function, so you are removing event listener which isn't there. Just try to put
board_click_default.bind(player) == board_click_default.bind(player)
into the console and you will get false
. So correct code should look like this:
var board_click_default = function(x,y) {
// do somethis
console.log("==x: " + x + "--y: " + y);
}.bind(player);
board.addEventListener("click", board_click_default);
board.removeEventListener("click", board_click_default);
When I use the board's method removeEventListener is seemly not work, like that: