# How to access $(this) with api.attachWidgetAction?

**URL:** <https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570>\
**Category:** Development\
**Created:** [Mai 2, 2016, 8:34 UTC](https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570 "2016-05-02T20:34:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)\
**Post date:** [Mai 3, 2016, 4:18 UTC](https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570/3 "2016-05-03T16:18:37Z")

</div>

Thanks for the explanation. Very helpful. 🙆‍♀️

Does `api.attachWidgetAction` have access to `attrs` (my guess is no since I tried with no luck). If no, how exactly would a post menu button action have access. Here’s an example of what I mean:

```
api.addPostMenuButton('drink-coffee', (attrs) => {
        return {
          action: 'drink-coffee',
          icon: 'coffee',
          className: 'drink-coffee',
          title: 'Coffee',
          data: {
            'coffee-link': attrs.shareUrl
          },
          position: 'first'
        };
      });

```

So here we want the action `drink-coffee` to link to the `data-coffee-link` as defined in the `addPostMenuButton`. Since `attachWidgetAction` does not have access to `attrs` (assumingly), where would we put some good ol’ JS to link to the `data-coffee-link`.

Apologies for basically asking for a tutorial 🙇‍♂️

---

_[View the full topic](https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570)._
