gar1t
(Garrett)
19. April 2024 um 16:39
1
Ich versuche, von einer benutzerdefinierten Komponente mit diesem Ausschnitt im HTML-Body auf die API zuzugreifen:
<script type="text/discourse-plugin" version="0.8">
console.log("###########", api.getCurrentUser());
</script>
Dieser Ausschnitt erscheint jedoch nicht im Seiten-HTML.
Was ist hier der richtige Ansatz?
Übrigens, dies ist dieselbe Frage, die vor ein paar Jahren gestellt, aber nicht beantwortet wurde:
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 „Gefällt mir“
Hallo Garrett!
Wenn du diesen Code in den Head-Tab deines Themes oder deiner Theme-Komponente einfügst,
solltest du die Ausgabe in der Konsole des Browsers sehen können (hier wird kein HTML angezeigt):
Nützlicher Leitfaden zum Erlernen von Theme-Komponenten (auch Theme component Tag):
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 „Gefällt mir“
gar1t
(Garrett)
19. April 2024 um 16:58
3
Danke. Ich hatte diesen Code im Body-Bereich platziert.
Es überrascht mich, dass das Verhalten des Head-Bereichs hier anders ist. Es sieht so aus, als ob Discourse diese API-Snippets aus dem Body-Bereich entfernt. Andere Skriptelemente bleiben dort erhalten.
2 „Gefällt mir“
system
(system)
Geschlossen,
19. Mai 2024 um 16:59
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.