gar1t
(Garrett)
19.Апрель.2024 16:39:33
1
Я пытаюсь получить доступ к API из пользовательского компонента с помощью следующего фрагмента в теле HTML:
<script type="text/discourse-plugin" version="0.8">
console.log("###########", api.getCurrentUser());
</script>
Однако этот фрагмент не отображается в HTML страницы.
Какой правильный подход в данном случае?
Кстати, это тот же вопрос, который задавался несколько лет назад, но на него так и не ответили:
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]
Привет, Гаррет!
Если вы добавите этот код во вкладку Head компонента темы вашей темы,
вы сможете увидеть вывод в консоли браузера (здесь не отображается HTML):
Полезное руководство по изучению компонента темы (также тег #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…
gar1t
(Garrett)
19.Апрель.2024 16:58:27
3
Спасибо. Я разместил этот код в разделе body.
Для меня удивительно, что поведение head здесь отличается. Похоже, Discourse удаляет эти фрагменты API из раздела body. Другие элементы script там сохраняются.