Copy link to clipboard
Copied
FRAME1
this.btn.addEventListener("click", clickHandler.bind(this)); - works great
FRAME2
this.btn2.addEventListener("click", clickHandler2.bind(this)); - doesn't work
I used the same code and just appended 2 - btn2 and clickHandler2.
I even created a new button btn2 (with an instance etc...)
As it didn't work I thought there may be a problem with the event listeners so I removed them
from frame1
this.btn.removeEventListener("click", clickHandler);
I'm afraid the btn2 still doesn't work on frame2.
1 Correct answer
Whenever something doesn't work that you think should, always, ALWAYS verify your assumptions.
Does this.btn2 exist?
Does clickHandler2 exist?
Does clickHandler2 actually execute?
And I don't mean verify with your eyeballs. I mean verify with code that explicitly accesses the variable or function or object, and displays an alert or console.log or whatever with the result of that access.
Copy link to clipboard
Copied
Whenever something doesn't work that you think should, always, ALWAYS verify your assumptions.
Does this.btn2 exist?
Does clickHandler2 exist?
Does clickHandler2 actually execute?
And I don't mean verify with your eyeballs. I mean verify with code that explicitly accesses the variable or function or object, and displays an alert or console.log or whatever with the result of that access.
Copy link to clipboard
Copied
Excellent answer. I'm a teacher too, I like your style and your profile picture, slightly menacing lol.
Everything exists but you made me go over everything with a fine-tooth comb.
The btn2 button was not placed where it was supposed to be.
Cheers

