How to fire a JavaScript code in only one topic page?

Hey! I really hope you can help me with this, please!

Is there a way for me to edit the theme head component so that when the users click on the topic “welcome” a JavaScript code will fire but then as soon as they leave this topic page into any other topic, the JavaScript will stop working?

I have been successful at making it run only when one arrives at the page ‘welcome’ but then the JavaScript code will keep running throughout the website until one refreshes the site (F5).

Addition: I’m assuming didInsertElement in ( app/components/topic-title.js ) will be helpful?

2 Likes

Hey @gassim :wave:

This sounds like an XY problem. Let’s try to take a step back and fix the main issue.

What are you trying to do, and can you share the code you’re using to achieve that?

2 Likes