Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32227

Re: remove listener

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: remove listener
Date 2017-01-21 06:07 +0100
Organization PointedEars Software (PES)
Message-ID <4137428.rnE6jSC6OK@PointedEars.de> (permalink)
References <_N2dnVScZPU0SR_FnZ2dnUU7-IXNnZ2d@westnet.com.au>

Show all headers | View raw


Andrew Poulos wrote:

> why does doing this fail to remove any of the listeners

It does not fail; it is just ineffective.

> when I pass valid values for 'me', 'elem' and 'i'?
> 
> elem.removeEventListener("click", function(m) {
>    return function() {
>      me.show(m);
>    };
> }(i));

You are attempting to remove an event listener that was not added in the 
first place.  Each use of a function expression creates a new Function 
instance.
 
> Is it because event handlers can't be anonymous?

No.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 14:25 +1100
  Re: remove listener Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-21 06:07 +0100
    Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 17:37 +1100
      Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 20:35 +1100
        Re: remove listener Andrew Poulos <ap_prog@hotmail.com> - 2017-01-21 20:55 +1100
          Re: remove listener Scott Sauyet <scott@sauyet.com> - 2017-01-21 19:24 +0000
          Re: remove listener Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-23 20:14 +0100

csiph-web