Stimulus and Rails UJS

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

1 Like