ahs10
04-20-2009, 06:54 PM
i have the following code...
for (i=0; i<5; i++) {
var t = document.getElementById('div'+i);
t.addEventListener('mouseover',function () {adminStyle(this.id,'over');},false);
t.addEventListener('mouseout',function () {adminStyle(this.id,'out');},false);
t.addEventListener('dblclick',function () {lightWindow('linkDemo');},false);
}
i used an anonymous function because i was having trouble passing values to the name functions. now that i'm using anonymous function though, i don't know how to remove the event listener. this doesn't work...
for (i=0; i<5; i++) {
var t = document.getElementById('div'+i);
t.removeEventListener('mouseover',function () {adminStyle(this.id,'over');},false);
t.removeEventListener('mouseout',function () {adminStyle(this.id,'out');},false);
t.removeEventListener('dblclick',function () {lightWindow('linkDemo');},false);
}
i believe in order to solve my issue i need to know one of two things...
1 - how do i addEventListener and pass variables to the function that is to be called on the specified event?
or
2 - how do i removeEventListener if it's an anonymous function?
got the time, and i'd love the answer to both. if not, just one will do fine, thanks for your time =)
for (i=0; i<5; i++) {
var t = document.getElementById('div'+i);
t.addEventListener('mouseover',function () {adminStyle(this.id,'over');},false);
t.addEventListener('mouseout',function () {adminStyle(this.id,'out');},false);
t.addEventListener('dblclick',function () {lightWindow('linkDemo');},false);
}
i used an anonymous function because i was having trouble passing values to the name functions. now that i'm using anonymous function though, i don't know how to remove the event listener. this doesn't work...
for (i=0; i<5; i++) {
var t = document.getElementById('div'+i);
t.removeEventListener('mouseover',function () {adminStyle(this.id,'over');},false);
t.removeEventListener('mouseout',function () {adminStyle(this.id,'out');},false);
t.removeEventListener('dblclick',function () {lightWindow('linkDemo');},false);
}
i believe in order to solve my issue i need to know one of two things...
1 - how do i addEventListener and pass variables to the function that is to be called on the specified event?
or
2 - how do i removeEventListener if it's an anonymous function?
got the time, and i'd love the answer to both. if not, just one will do fine, thanks for your time =)