1,105,177 Community Members

How to "undo" a listener?

Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

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.

Member Avatar
pritaeas
mod_pritaeas
11,292 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

canvas.removeEventListener should work, but only with named functions.

Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

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?

Member Avatar
pritaeas
mod_pritaeas
11,292 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

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.

Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

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.

Member Avatar
riahc3
 
1,397 posts since May 2008
Reputation Points: 45 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 18 [?]
Team Colleague
 
0
 

Autosolved.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article