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

**URL:** <https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570>\
**Category:** Development\
**Created:** [5월 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:** 2

<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:** [5월 3, 2016, 3:09오후 UTC](https://meta.discourse.org/t/how-to-access-this-with-api-attachwidgetaction/43570/2 "2016-05-03T15:09:51Z")

</div>

You can’t access selectors like that when using the widget code (with a couple of exceptions).

The reason is the widgets can be re-rendered at any time and replaced with new HTML. So even if you added an attribute from some other process it would likely be painted over when it refreshed.

On the other hand, if you were able to create that `data-*` attribute as part of a decorator, you should already have it in `attrs` and you can access that in your action as `this.attrs`.

---

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