I’ve built a layout using a combination of turbo-stream
and turbo-frame
. In one frame I’m streaming a list of objects. When clicked, the show action loads into another frame. It’s a pretty conventional layout and it works great, until I need to provide a link to a single object somewhere in my app. What happens then is the show action renders on its own in the browser, just like it would normally.
My conceptual question is: how do I essentially “reassemble” my page when a user clicks on a link to view one of these objects—loading the show
action into a frame within the index
?
Think email → viewer, where you want any reference to an individual email to be loaded into the full app UI rather than any individual email just rendering on its own.
The skeleton of my page is basically this:
<div>
<main>
<%= turbo_stream_from "contacts" %>
<div id="contacts">
Contacts are listed here, and wired up to the 'details' turbo frame below.
</div>
</main>
<sidebar>
<%=turbo_frame_tag :details do %>
Contact details load here. Any time a user follows a link like "contact/123" I'd like it to load "/contacts", with the `show' action rendered here.
<% end %>
</sidebar>
</div>
I hope this makes sense, and thanks!