Hey.
I am banging my head here not being able to do seemingly quite straightforward thing.
Granted, i am still new to turbo, specially when it comes to rails.
So, what i would like to achieve is:
- person clicks on a “Like” component
- replace this same component with new count and other logic returned by controller
- display flash message to inform user it was successfull
- this component has a Bootstrap Tooltip on it
So, first i though, i need turbo stream. So i created link_to, which i though will request a turbo_stream response. I was wrong. I searched and found some people do link_to :get as workaround but that doesn’t work either for me.
Then, i went and created turbo-frame and it works perfectly, except that i can do only one render, meaning i loose flash message - i can only update the Like component. I can also do event listener on frame-loaded to initialize a tooltip on newly rendered component. But i still miss flash.
Then i though OK, let’s go with stimulus controller, and send a turbo_stream request.
Fine, I can now render Flash + replace component, but now i don’t know how to initialize a Tooltip on the rendered component.
Whichever way I go, i miss something.
Would anyone be so kind and explain what is correct way, or best way?
So to repeat, the component (be it button_to, link_to, something else) needs to be updated in-place from controller, tooltip needs to work after it has been rendered, and i also need to show flash message.