# Pairing data-action with data-confirm in rails?

**URL:** <https://discuss.hotwired.dev/t/pairing-data-action-with-data-confirm-in-rails/749>\
**Category:** General\
**Created:** [April 16, 2019, 6:16pm UTC](https://discuss.hotwired.dev/t/pairing-data-action-with-data-confirm-in-rails/749 "2019-04-16T18:16:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![skatkov](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/skatkov/32/710_2.png) [@skatkov](https://discuss.hotwired.dev/u/skatkov)\
**Post date:** [April 17, 2019, 6:32am UTC](https://discuss.hotwired.dev/t/pairing-data-action-with-data-confirm-in-rails/749/3 "2019-04-17T06:32:47Z")

</div>

Hey @kaspermeyer

Thanks for your suggestion. I actually solved this already, I got an idea based on your answer in another thread:

> [@Stimulus and Rails UJS](https://discuss.hotwired.dev/t/stimulus-and-rails-ujs/587/7):
>
> You can have an action that triggers on ajax success like so: \<form data-action="ajax:success-\>controller-name#actionName"\> A complete list of ajax lifecycle events can be found here: [https://edgeguides.rubyonrails.org/working\_with\_javascript\_in\_rails.html#rails-ujs-event-handlers](https://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers)

Now I remove form from page only after ‘ajax:success’ happened. And that completely solves my issue!

---

_[View the full topic](https://discuss.hotwired.dev/t/pairing-data-action-with-data-confirm-in-rails/749)._
