Ask A Question

Notifications

Youโ€™re not receiving notifications from this thread.

Auto-submitting Forms & Custom Turbo Stream Actions Discussion

Awsome work Chris. Thanks!

Reply

Glad you liked it Ahmed!

Reply

If you would apply this feature on several elements on the same page or multiple pages what is the best approach to do so?

Reply

The only way I see it now is duplicate code for every element. Other solutions?

Reply

Great episode. I think the best solution to remove an element would be to use a stimulus controller. And this way, it can be re-used easily and we don't have to keep writing the turbo_stream_action_tag. So something as simple as: <span id="saved" data-controller="remove" data-remove-timeout-value="5000">Saved</span> would do it and can be re-used.

Reply

Yep! I think a Stimulus controller for remove probably makes the most sense, however this was a great example to show off a small custom Turbo Stream.

Reply

It was. Thank you for this ๐Ÿ‘

Reply

Excellent episode and would really like to see more use cases for custom turbo stream actions. Opens up a world of opportunities!

Reply

They sure do and we will absolutely cover more ideas for them. Next episode is going to walk through using them to implement browser notifications. ๐Ÿ‘

Reply

Ooooh, VERY interested in that one.

Reply

Oh, yes please!

Reply

Love this, Chris: thank you!

Reply

Glad you're enjoying it. We'll keep doing more Hotwire stuff!

Reply

Did you remove the flash message behind the scenes or is it because you added the 'turbo_stream' action that it longer displays the "ticket is saved" message?

Reply

A flash message is set for the next full HTTP request. A turbo stream response is only a partial update to the existing page, so you would need to add a turbo stream to inject a flash message if you wanted to keep that.

Reply
Join the discussion
Create an account Log in

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

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

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