I’m still trying to understand the whole hotwire way of doing things. My application.js has these two lines:
import Rails from "@rails/ujs"
Rails.start()
Should ujs still be used? should I keep those lines?
The reason why I’m asking this is because resetting a form, like it’s shown in the video it hotwire.dev, doesn’t reset the disable state of a button which is set automatically by ujs I believe (am I right?). I’m trying to find a way to re-enable it with JavaScript, but I can’t find anything clean. I could disable the functionality with:
Oh, that’s what you meant by new app. Sorry… the app exists already, it’s new in the sense that I created it less than a month ago, I don’t have a lot of code to convert.
Well if the app is very small and you don’t need webpacker, you could always create a new app as written above and regenerate your migrations etc to move your code over.
Mmmm…I say this because in this new app there isn’t even an application.js. Maybe someone else can provide a better answer for just cleaning up your current apps settings.
I’ve been removing Webpacker from projects where possible, its so much simpler to just include the js files you need, do you know if there is a recommended way to use active_storage and action_text without Webpacker ?
Or would you just switch to something like Shrine and Froala ?
I’m personally keeping with Webpacker, it became the standard in the JavaScript world and I want to be able to consume JavaScript libraries in a mainstream way.
Rails-Ujs may still be helpful for handling ajax for you (adding the csrf tokens etc), it’s possible Hotwire makes ajax less important but the bigger the app gets it’s very possible you will need to do something with ajax at some point.