Hi there, I have a page that lists gizmos. The application layout looks like this:
<%= turbo_frame_tag :main do %>
<%= yield %>
<% end %>
<%= turbo_frame_tag :modal %>
Each link in the gizmo list looks like this:
<%= link_to gizmo.name, gizmo, data: { turbo_frame: “modal” } %>
Clicking a gizmo link loads the Gizmos#show page into the modal on top of the list. So far, so good.
It’s also possible to reach the Gizmo#show page via deep link (/gizmos/1234). When reached in this manner, I still want the list to appear under the modal, so the #show page contains a :main frame in which to lazy load it:
<%= turbo_frame :main, src: gizmos_path, loading: lazy %>
<%= turbo_frame :modal do %>
<%# display Gizmo stuff here %>
<% end %>
That works.
The problem I’m facing is that, now, when I access the #show page from the original list, Turbo insists on performing the lazy load even though the frame’s already loaded. It doesn’t affect page performance as it’s a lazy load, but it’s still unnecessary traffic and it makes the background blink.
What I need is a conditional frame load. Has anyone come up with a cunning way to handle this? Thanks!