problems with event listeners on various frames

Explorer ,
Feb 26, 2021 Feb 26, 2021

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.

 

Views

49

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 26, 2021 Feb 26, 2021
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.

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 26, 2021 Feb 26, 2021

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.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 26, 2021 Feb 26, 2021

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

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines