由于 Discourse 是一个单页应用程序 (SPA),依赖文档的“DOMContentLoaded”事件将不会很有帮助,因为文档 DOM 始终是“已加载”的,但元素可能缺失。您需要改用 @merefield 提到的组件,或者类似这样的方法:How do you force a script to refire on every page load in Discourse? - #5 by simon
Alteras
(Steven Chang)
4
相關主題
| 話題 | 回覆 | 觀看 | 活動 | |
|---|---|---|---|---|
| Custom javascript gets only applied after refresh, creating categories for location plugin | 9 | 144 | 2025年八月13日 | |
| How to add Javascript to Footer Of Posts? | 3 | 947 | 2021年十月10日 | |
| A better way to implement custom jQuery code? | 3 | 561 | 2021年二月18日 | |
| Executing js after DOM loaded | 6 | 3767 | 2018年十一月30日 | |
| How do you force a script to refire on every page load in Discourse? | 38 | 21442 | 2020年三月12日 |