New Discussion

Notifications

You’re not receiving notifications from this thread.

How Do Show Loading Indicator On A Turbo(Stimulus) Form ?

6
Ruby

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

I figured this out

Suleiman, how you do that? can you please share the code?

This post must be removed as it has no helpful content.

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

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 91,926+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.