gar1t
(Garrett)
19 Abril, 2024 16:39
1
Estoy intentando acceder a la API desde un componente personalizado con este fragmento en el cuerpo del HTML:
<script type="text/discourse-plugin" version="0.8">
console.log("###########", api.getCurrentUser());
</script>
Sin embargo, este fragmento no aparece en el HTML de la página.
¿Cuál es el enfoque correcto?
Por cierto, esta es la misma pregunta planteada hace unos años pero sin respuesta:
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 Me gusta
¡Hola Garrett!
Si colocas este código en la pestaña Head de tu tema o componente temático,
deberías poder ver la salida en la consola del navegador (aquí no se muestra ningún HTML):
Guía útil para aprender sobre componentes temáticos (también la etiqueta 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 me gusta
gar1t
(Garrett)
19 Abril, 2024 16:58
3
Gracias. Había colocado este código en la sección del cuerpo.
Me sorprende que el comportamiento de la cabeza aquí sea diferente. Parece que Discourse está eliminando estos fragmentos de API de la sección del cuerpo. Otros elementos de script se conservan allí.
2 Me gusta
system
(system)
Cerrado
19 Mayo, 2024 16:59
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.