Receiving an event after the form is replaced seems impossible. The element that has fired the event is no longer available and rails-ujs silently can’t do anything.
There are dozens of issues and questions and people facing the same problem. Many of the answers are very old and even include jquery-ujs which probably leads to further confusion.
Some examples below:
My questions is - what could we attach and listen to to get a notification about a form replacement? Is there such a thing? Should there be?
https://github.com/rails/jquery-ujs/issues/223
https://github.com/rails/rails/issues/30692 https://github.com/rails/rails/issues/32438