# Unbind data-actions

**URL:** https://discuss.hotwired.dev/t/unbind-data-actions/265
**Category:** General
**Created:** [April 23, 2018, 7:57pm UTC](https://discuss.hotwired.dev/t/unbind-data-actions/265 "2018-04-23T19:57:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![randohinn](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/randohinn/32/209_2.png) [@randohinn](https://discuss.hotwired.dev/u/randohinn)
#### Post date: [April 23, 2018, 7:57pm UTC](https://discuss.hotwired.dev/t/unbind-data-actions/265/1 "2018-04-23T19:57:34Z")

</div>

What’s currently the best way to unbind a data-action event?

---

<div class="post-metadata">

### Author: ![adrienpoly](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/adrienpoly/32/78_2.png) [@adrienpoly](https://discuss.hotwired.dev/u/adrienpoly)
#### Post date: [April 24, 2018, 10:50am UTC](https://discuss.hotwired.dev/t/unbind-data-actions/265/2 "2018-04-24T10:50:00Z")

</div>

I have no idea if it is a good practice or not but here is a pattern that I have used recently.

Rather than updating the html to remove the specific string in the `data-action` attribute, I define in my controller a `preventThisAction` boolean state variable.  
Then before doing anything in my action I check this value and return immediately if the action is disabled.

Here is a little example (inspired by a previous example of @javan 😉 )  
[https://jsfiddle.net/adrienpoly/gLz7pfu5/4/](https://jsfiddle.net/adrienpoly/gLz7pfu5/4/)

I have not tested to remove the action from the Html, I suppose it would work, it is just too painful to manage (IMHO) when you have several actions.
