How to prevent effects of async loading vs direct loading?

I have a topic page: Topic
This page is particular, it has a <div id="om-xddddihwxnstqcdk-holder"></div> into the content, this div is converted into this result:

The operation of converting the id into the form is made by a js script, that i embedded into the page.
The script actually works perfectly, but only when the page is loaded directly (or when you reload it in the browser)

If you try to access it through other pages of the forum like for example: https://forum.uppa.it/c/medicina from here it is the first topic (Manovre antisoffocamento nel bambino fino a 12 mesi)
The script won’t be loaded.

Than, when the page is loaded async. the result is that the js form is not displayed, but i need to fix this thing. Is there a way i can do that?

PS: the div id works because i created a plugin with the help of @cpradio

1 Like

If I had to guess, you would have to register to some sort of event that indicates the page is changing and run your init script again to look for the div and id to replace.

I think someone had a similar question on here at one point, but my searches are struggling to find it, probably my lack of keywords that would make it pop up.

1 Like

I tried to find a result into the meta without any luck :frowning: as i did before finding that old topic where i had the pleasure to met you!

Here we go
https://meta.discourse.org/t/wip-list-of-all-the-hooks-in-discourse/11505

I think you will want Discourse.PageTracker.current() (assuming these are still valid and haven’t changed)

3 Likes