I changed the template upload-selector.hbs
Before
After
The template works well, but my script refuses to work
I inserted this code in the “Header” tab
Please tell me what could be the problem?
Summary
Mikhail_Tyuftyaev is experiencing issues with a custom script not working after modifying a template. They inserted the code in the “Header” tab, but it’s not functioning as expected. merefield suggested that the code should be written within Ember hooks, as $document.ready is not suitable for an Ember app. Mikhail_Tyuftyaev questioned this, referencing the Developer’s guide to Discourse Themes, but merefield clarified that while the event may still fire, it’s not reliable for intricate tasks.
Mikhail_Tyuftyaev requested documentation to implement a solution, and merefield recommended interpreting the source code, using the Ember Guides, and studying existing plugins or Theme Components. Mikhail_Tyuftyaev thanked merefield for the advice and will attempt to solve the issue.
I changed the template upload-selector.hbs
Before
You must write this stuff within Ember hooks because eg $document.ready is meaningless in an Ember app.
You may need to look at modifying the js of the modal’s controller depending on your needs.
Thanks for your reply. Why then in the manual Developer’s guide to Discourse Themes say what can be used?
It still works I guess for some use cases (the event will still fire) but if you want to do something intricate in a specific part of the interface I would not use such an event because it does not guarantee availability of some elements of the dom, unlike the ember hooks for components, for example.
Please tell me, is there any documentation so that I can implement something similar?
Usually with these things you will have to interpret the source code and use the Ember Guides to help you.
Additionally studying prior art in existing plugins or Theme Components can be really helpful.
Thanks. I will try to solve it