How Do Show Loading Indicator On A Turbo(Stimulus) Form ?
I am learning rails by building a project. I am using the turbo frames for the form.
I would like to add a loading indicator to the submit button just like the one on this forum when you comment on a thread. Has anyone any idea on how I can achieve that ?
Best regards,
Suleiman Nassor
Can't post links but there is a nice example here:
www mikewilson . dev/posts/using-hotwire-with-rails-for-a-spa-like-experience
Hey Suleiman, that's a cool project! Using Turbo Frames for forms is a neat way to keep things snappy. For the loading indicator, I've found success by disabling the button and swapping its text with a spinner inside the turbo:before-stream-render and turbo:after-stream-render events. It's a fun challenge, almost like trying to beat my high score in the Dinosaur Game while waiting for the form to process! Hope that helps get you pointed in the right direction. Good luck!
Learning Rails with Turbo Frames is a great way to enhance interactive forms. If you want to add a loading indicator to your submit button, you can use JavaScript to disable the button and show a spinner during processing. This approach improves user experience, just like the feedback you see when playing games such as Funny Shooter 2