I am developing a single-page app using turbo frames. The page displays a list of objects and for each of them a link “Show item”. It should be noted that this index page has been rendered in a turbo_frame after submitting a post form.
Is it possible to show the details of the selected single item and hide the other items in the list, without redirecting to a new url?
I have tried several ways, with or without a new turbo frame tag. I have tried both link_to
and button_to
method helpers. After hitting the button, the app shows the correct content, but the page is redirected to url home/show/1
with a complete reload of the page (turbo not working?):
bikes/index.html.erb
<%= turbo_frame_tag "bikes_frame" do %>
<% @bikes.each do |bike| %>
<%= turbo_frame_tag bike do %>
<%= render bike %>
<%= link_to "Show this bike", bike %>
<% end %>
<% end %>
<% end %>
bikes/show.html.erb
<%= turbo_frame_tag "bikes_frame" do %>
<%= render @bike %>
<% end %>