I upgraded my Rails application to Rails 7. I know that Turbolinks and Rails UJS actually are replaced by the Hotwire combination of Stimulus and Turbo in Rails 7, but I wanted to know whether I can still use UJS and if yes, why is it not working?
My method that is not working looks like this:
submit(event) {
this.errorTarget.classList.add("hidden")
Rails.fire(this.formTarget, "submit")
console.log('hi')
}
The console.log works. When I click on an element, it used to change with this code, but now it doesn't change anymore. Rails.fire
simply does not fire anymore and there is no error in the log or in the network part when I inspect the website.
I feel like I am missing something crucial here, but I don't know what.
./bin/importmap pin @rails/ujs@7
to pin it to version 7. Otherwise you might end up loading @rails/ujs@6 at the moment. – Tawannatawdry