gar1t
(Garrett)
19 Aprile 2024, 4:39pm
1
Sto cercando di accedere all’API da un componente personalizzato con questo snippet nel corpo HTML:
<script type="text/discourse-plugin" version="0.8">
console.log("###########", api.getCurrentUser());
</script>
Questo snippet, tuttavia, non appare nell’HTML della pagina.
Qual è l’approccio corretto?
A proposito, questa è la stessa domanda posta qualche anno fa ma senza risposta:
I have tried to add custom html through jquery using plugin api events like api.onAppEvent(), api.decorateWidget(), etc…, in Edit CSS/HTML >> /head section. But, the events which i tried is not triggering the jquery on page load.
So, i am little bit confused about what event need to use. Because that event should trigger the jquery throughout the site on page load instead of blocking the scripts on particular pages.
Here is the code which i tried,
[SearchButtonIssue]
2 Mi Piace
Ciao Garrett!
Se inserisci questo codice nel tuo tema, nella scheda Head del componente del tema,
dovresti essere in grado di vedere l’output nella console del browser (qui non viene visualizzato alcun HTML):
Guida utile per saperne di più sui componenti del tema (anche il tag Theme component ):
Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components.
This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to:
Themes vs. Theme Compon…
1 Mi Piace
gar1t
(Garrett)
19 Aprile 2024, 4:58pm
3
Grazie. Avevo inserito questo codice nella sezione body.
Mi sorprende che il comportamento della head qui sia diverso. Sembra che Discourse stia rimuovendo questi snippet API dalla sezione body. Altri elementi script vengono mantenuti lì.
2 Mi Piace
system
(system)
Chiuso
19 Maggio 2024, 4:59pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.