# My script is not working

**URL:** https://meta.discourse.org/t/my-script-is-not-working/187902
**Category:** Development
**Created:** [April 23, 2021, 1:07pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902 "2021-04-23T13:07:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Mikhail\_Tyuftyaev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikhail_tyuftyaev/32/237998_2.png) [@Mikhail\_Tyuftyaev](https://meta.discourse.org/u/Mikhail_Tyuftyaev)
#### Post date: [April 23, 2021, 1:07pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/1 "2021-04-23T13:07:02Z")

</div>

I changed the template [upload-selector.hbs](https://github.com/discourse/discourse/blob/dc6b547ed89f652b5406489d76140b76cf8e0d1d/app/assets/javascripts/discourse/app/templates/modal/upload-selector.hbs)  
Before

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/b/7bb7ba729b3a9cbbfa42787803e8d42719b8f84f.png)  
After  
 ![image](https://global.discourse-cdn.com/meta/original/3X/1/9/1926e16d474f4884d6e3170d8f5aaa882243a787.png)  
The template works well, but my script refuses to work  
 ![image](https://global.discourse-cdn.com/meta/original/3X/b/2/b2f9b6861dd61371da46920677414f6326e2d39b.png)  
I inserted this code in the “Header” tab  
Please tell me what could be the problem?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [April 23, 2021, 1:18pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/2 "2021-04-23T13:18:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Mikhail\_Tyuftyaev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikhail_tyuftyaev/32/237998_2.png) [@Mikhail\_Tyuftyaev](https://meta.discourse.org/u/Mikhail_Tyuftyaev)
#### Post date: [April 23, 2021, 1:23pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/3 "2021-04-23T13:23:32Z")

</div>

Thanks for your reply. Why then in the manual [Developer’s guide to Discourse Themes](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-c-2) say what can be used?

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/2/72ca2836647addcd92c37a01ebbdf0c3c2a5d1fd.png)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [April 23, 2021, 1:25pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/4 "2021-04-23T13:25:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Mikhail\_Tyuftyaev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikhail_tyuftyaev/32/237998_2.png) [@Mikhail\_Tyuftyaev](https://meta.discourse.org/u/Mikhail_Tyuftyaev)
#### Post date: [April 23, 2021, 1:27pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/5 "2021-04-23T13:27:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [April 23, 2021, 1:28pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/6 "2021-04-23T13:28:00Z")

</div>

Usually with these things you will have to interpret the source code and use the [Ember Guides](https://guides.emberjs.com/v3.12.0/) to help you.

Additionally studying prior art in existing plugins or Theme Components can be really helpful.

---

<div class="post-metadata">

### Author: ![Mikhail\_Tyuftyaev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mikhail_tyuftyaev/32/237998_2.png) [@Mikhail\_Tyuftyaev](https://meta.discourse.org/u/Mikhail_Tyuftyaev)
#### Post date: [April 23, 2021, 1:30pm UTC](https://meta.discourse.org/t/my-script-is-not-working/187902/7 "2021-04-23T13:30:49Z")

</div>

Thanks. I will try to solve it
