My script is not working

I changed the template upload-selector.hbs
Before
image
After


The template works well, but my script refuses to work
image
I inserted this code in the “Header” tab
Please tell me what could be the problem?

1 Like

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.

2 Likes

Thanks for your reply. Why then in the manual Developer’s guide to Discourse Themes say what can be used?

1 Like

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.

2 Likes

Please tell me, is there any documentation so that I can implement something similar?

1 Like

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.

3 Likes

Thanks. I will try to solve it

2 Likes