How to "undo" a listener?
I have a listener on canvas for whenever I click on it. At certain moments (like when a checkbox is checked) I want to disable that listener and make clicking on it do nothing. How do I do this?
jQuery is allowed.
Related Article: Proper way to do JavaScript-based OAuth
is a JavaScript / DHTML / AJAX discussion thread by Dani that has 4 replies, was last updated 3 months ago and has been tagged with the keywords: oauth.
riahc3
1,295 posts since May 2008
Reputation Points: 62
Solved Threads: 13
Skill Endorsements: 11
canvas.removeEventListener should work, but only with named functions.
pritaeas
Posting Prodigy
9,268 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86
canvas.removeEventListener should work, but only with named functions.
OK and then how do I had it back?
I just had a thought: Would disabling canvas be enough?
riahc3
1,295 posts since May 2008
Reputation Points: 62
Solved Threads: 13
Skill Endorsements: 11
OK and then how do I had it back?
Not sure what you mean, but if you are adding anonymous functions, you can't remove them (apparently).
Disabling may work, depending on the event I guess.
pritaeas
Posting Prodigy
9,268 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86
Not sure what you mean, but if you are adding anonymous functions, you can't remove them (apparently).
Disabling may work, depending on the event I guess.
I have this:
handleCanvasMouseDown: function(e){
this.drawManager.unSelectAllPointsOfTheDrawingThatHasPoints();
},
handling the mouse event on a canvas. A simple if
if it is checked
return false
else if it is not checked
this.drawManager.unSelectAllPointsOfTheDrawingThatHasPoints();
Does not work. It stil continues. And yes, it goes into the checked because a alert does show up.
riahc3
1,295 posts since May 2008
Reputation Points: 62
Solved Threads: 13
Skill Endorsements: 11
riahc3
1,295 posts since May 2008
Reputation Points: 62
Solved Threads: 13
Skill Endorsements: 11