How to prevent effects of async loading vs direct loading?


(Benjamin Meghnagi Rozenberg (Broz)) #1

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: Medicina - Il forum di UPPA 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


Advertising Plugin for Discourse - Serve Ads on your Discourse Forum (Official Endorsed)
(cpradio) #2

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.


(Benjamin Meghnagi Rozenberg (Broz)) #3

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!


(cpradio) #4

Here we go

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