# Widget action not found

**URL:** https://meta.discourse.org/t/widget-action-not-found/46903
**Category:** Development
**Created:** [July 6, 2016, 3:15pm UTC](https://meta.discourse.org/t/widget-action-not-found/46903 "2016-07-06T15:15:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![piratdavid](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@piratdavid](https://meta.discourse.org/u/piratdavid)
#### Post date: [July 6, 2016, 3:15pm UTC](https://meta.discourse.org/t/widget-action-not-found/46903/1 "2016-07-06T15:15:05Z")

</div>

I’m using the new widget api to add a download button to the post menu. The button renders correctly but my action is not called. What am I doing wrong? I am attach an action in the same initializer as I am adding the button as following.

```
withPluginApi('0.1', api => {

    api.addPostMenuButton('download', (post) => {
      if (post.upload_url) {
        return {
          action: 'downloadFile',
          icon: 'download',
          className: 'download-file',
          title: 'files.download',
          position: 'first'
        };
      }
    });

    api.attachWidgetAction('post', 'downloadFile', function() {
      const post = this.model;
      const upload_url = post.get('upload_url');
      return upload_url;
    });

});

```

I get the following error.

`WARNING: downloadFile not found`

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [July 6, 2016, 3:19pm UTC](https://meta.discourse.org/t/widget-action-not-found/46903/2 "2016-07-06T15:19:54Z")

</div>

> [@piratdavid](#):
>
> api.attachWidgetAction(‘post’, ‘downloadFile’, function() {

This should be

```plaintext
api.attachWidgetAction('post-menu', 'downloadFile', function() {

```

Example to compare it to

> <https://github.com/cpradio/discourse-plugin-show-raw-button/blob/master/assets/javascripts/discourse/initializers/show-raw-button.js.es6>

---

<div class="post-metadata">

### Author: ![piratdavid](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@piratdavid](https://meta.discourse.org/u/piratdavid)
#### Post date: [July 7, 2016, 8:36am UTC](https://meta.discourse.org/t/widget-action-not-found/46903/3 "2016-07-07T08:36:58Z")

</div>

Wow thanx! Of course it should be attached to the widget not the model. 🙂
