S
sylver
Hi,
Unregistering event listeners (or memory allocation) is a good
practice in programming, but do we need to use removeEventListener()
for all addEventListener() implementation?
Please consider this code:
if(choice == a)
button.addEventListener("click", function () {alert('just trying
anonymous function over here');}, true);
else
button.addEventListener("click", function () {alert('here's where
the else go');}, true);
As you can see, there are 2 different functions (or maybe more) that
may be attached to the button onclick event, depending on user's
choice, and they are going to invoke anonymous functions.
Questions:
===========
1) Previous searches in the google groups suggested that there aren't
a removeALLEventListener method? or is there?
2) If i remove the button, using either removeChild() method or by
closing the tab/window, will the event listener be removed as well?
Please help.
Thanks so much
Unregistering event listeners (or memory allocation) is a good
practice in programming, but do we need to use removeEventListener()
for all addEventListener() implementation?
Please consider this code:
if(choice == a)
button.addEventListener("click", function () {alert('just trying
anonymous function over here');}, true);
else
button.addEventListener("click", function () {alert('here's where
the else go');}, true);
As you can see, there are 2 different functions (or maybe more) that
may be attached to the button onclick event, depending on user's
choice, and they are going to invoke anonymous functions.
Questions:
===========
1) Previous searches in the google groups suggested that there aren't
a removeALLEventListener method? or is there?
2) If i remove the button, using either removeChild() method or by
closing the tab/window, will the event listener be removed as well?
Please help.
Thanks so much