Since Discourse is an SPA, relying on the document “DOMContentLoaded” won’t be very helpful, since the document DOM is always “loaded” but the elements can be missing. Instead you’ll want to use Components as @merefield mentioned, or something like this: How do you force a script to refire on every page load in Discourse? - #5 by simon. This way every time the page changes, your code can check for the element you’re trying to change.
Alteras
(Steven Chang)
4
נושאים קשורים
| נושא | תגובות | צפיות | פעילות | |
|---|---|---|---|---|
| Custom javascript gets only applied after refresh, creating categories for location plugin | 10 | 85 | 12 בספטמבר, 2025 | |
| How to add Javascript to Footer Of Posts? | 3 | 885 | 10 באוקטובר, 2021 | |
| A better way to implement custom jQuery code? | 3 | 524 | 18 בפברואר, 2021 | |
| Executing js after DOM loaded | 7 | 3636 | 30 בדצמבר, 2018 | |
| How do you force a script to refire on every page load in Discourse? | 39 | 20966 | 26 בנובמבר, 2020 |