Auto-submitting Forms & Custom Turbo Stream Actions Discussion
Awsome work Chris. Thanks!
If you would apply this feature on several elements on the same page or multiple pages what is the best approach to do so?
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.
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.
Excellent episode and would really like to see more use cases for custom turbo stream actions. Opens up a world of opportunities!
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. ๐
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?
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.