angus
(Angus McLeod)
24 سبتمبر 2020، 11:13م
2
الطريقة التي تعاملتُ بها مع هذا في الماضي هي حزم الأزرار في دالة مساعدة HTML، والتي ستُظهر كود HTML الخام في القوالب الخام، ويمكنك بعد ذلك إدراجها عبر منفذ إضافة خام. إليك مثال على ذلك:
https://github.com/paviliondev/discourse-topic-previews/blob/master/assets/javascripts/discourse/helpers/preview-helpers.js.es6#L8
يتم التعامل مع نقر الزر في مكون عنصر قائمة الموضوع، على سبيل المثال:
https://github.com/paviliondev/discourse-topic-previews/blob/master/assets/javascripts/discourse/initializers/preview-edits.js.es6#L332
قد يكون لدى @merefield بعض الأفكار أيضًا
أيضًا، من المرجح أنك ستحتاج إلى استخدام هيكل مجلدات جافا سكريبت الخاص بالموضوع بدلاً من إضافة سكريبتات إلى header.html. انظر:
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,…
4 إعجابات