Reputation: 5451
I'd like to attach an event when a function is called, but it seems not working using addEventListener
...
My code :
function add () {
this.inputString.input.addEventListener('mouseover', toggle.call(this));
}
function toggle () {
$(this.tooltip).toggle();
}
Issue : the toggle()
function doesn't work. However, this.inputString.input
and this.tooltip
are not emtpy...
Upvotes: 0
Views: 43
Reputation: 1465
The apparent problem I see here is that you should attach a function to addEventListener
's second argument, not the call itself:
this.inputString.input.addEventListener('mouseover', toggle);
Then you should consider reviewing the toggle()
function itself.
What do you mean by this.tooltip
?
But this is out of scope of this question (about attaching events).
Upvotes: 1