# 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:** 4

<div class="post-metadata">

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

</div>

Yes you can use `this.attrs` to access the attributes within your action. If it’s not working, make sure you’re not using the ES2015 fat arrow function syntax, as it preserves `this` from the outer scope, which is _NOT_ what you want in this case.

For example:

```javascript
api.attachWidgetAction('post', 'annoyMe', function() {
   // this.attrs is the attrs
});

```

---

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