I'm testing out the Turbo Frames and so far the frame works as described in the documentation.
// First Page
= turbo_frame_tag "main" do
%p Testing Turbo Out
link_to "Test it", other_page_path
// Other View
= turbo_frame_tag "main" do
%p is this thing on?
Clicking the link on the first page replaces the content in that frame with what was in the other file.
However, if I ask the browser to do a full page reload, it reverts back to the original frame and doesn't display the one it was replaced with when the page is re-rendered.
If I want the full page to retain what it currently has if someone needs to hit the browser re-fresh, do I need to instead use turb streams?
I'm testing this out as a way to build a sidebar navigation that replaces the content area. So as this currently stands, if a full page browser refresh is requested, it reverts back to what the page displayed when first rendered.
CodePudding user response:
What you are asking is for the turbo-frame replacement to advance the browser history stack. This is done by this modification to the turbo-frame element:
%turbo-frame#main{ data: {turbo_action: :advance}}
I'm not using the turbo_frame_tag
helper here. I imagine that you could, but I just looked at my own app, and this is how I had done it.
It's described here in the hotwire docs.
You should see the url change when you load the "other view".
Does this work for you?