Here’s what I’m thinking, real quick (I might have better ideas later):
- In the turbo_frame that has the like button, you’ll have a button that posts the “like” and the resulting page will have the updated “like” turbo_frame. That will update that portion of the page automatically.
- For the tooltip, you’ll want to wrap that component in a Stimulus controller that properly wires up the
$(element).tooltip()
onconnect()
and properly dismounts the tooltip ondisconnect()
. - To update another part of the page with a flash message, instead of returning a
format.turbo_stream
, you can manually return aturbo_stream.replace
tag as part of your updated turbo_frame. Include the notice inside theturbo_stream.replace
and have it target the#notices
div elsewhere on the page.
<%= turbo_frame_tag dom_id(@like) do %>
<!-- The Like HTML -->
<% if notice.present? %>
<%= turbo_stream.replace "#notices" do %>
<!-- new notices go here -->
<% end %>
<% end %>
<% end %>