angus
(Angus McLeod)
24 Settembre 2020, 11:13pm
2
Il modo in cui ho affrontato questo problema in passato è stato incapsulare i pulsanti in un helper HTML, che renderizza l’HTML grezzo nei template grezzi, che puoi poi inserire tramite un outlet plugin grezzo. Ecco un esempio:
https://github.com/paviliondev/discourse-topic-previews/blob/master/assets/javascripts/discourse/helpers/preview-helpers.js.es6#L8
Il clic sul pulsante viene gestito nel componente topic-list-item, ad esempio:
https://github.com/paviliondev/discourse-topic-previews/blob/master/assets/javascripts/discourse/initializers/preview-edits.js.es6#L332
@merefield potrebbe avere anche qualche idea da condividere
Inoltre, probabilmente vorrai utilizzare la struttura delle cartelle JavaScript del tema invece di aggiungere script all’header.html. Consulta:
Complex theme javascript can be split into multiple files, to keep things nicely organised.
To use this functionality, simply add files to the /javascripts folder in your theme directory. These files can not be edited from the Discourse UI, so you must use the Theme CLI or source the theme from git .
Javascript files are treated exactly the same as they are in core/plugins, so you should follow the same file/folder structure. Theme files are loaded after core/plugins, so if the filenames match,…