DEV Community

loading...

Discussion on: Turbolinks is dead, long live Turbo ⚡

Collapse
k4ml profile image
Kamal Mustafa

Is it possible to change the target to other elements than <body>? For example I have website with top bar and left sidebar. When links are clicked, I want it to get loaded in the content area while the top and sidebar remains unchanged.

Collapse
joemasilotti profile image
Joe Masilotti Author

It sounds like you could benefit from Turbo Frames.

Turbo Frames decompose pages into independent contexts, which scope navigation and can be lazily loaded.

For example, set up your main content as a Turbo Frame and have link clicks only reload the content inside that area. Leaving your top bar and left sidebar untouched.

Collapse
k4ml profile image
Kamal Mustafa

So what I understand is that I only need to return response which contains <turbo-frame id ...> element. If the response have that frame, then turbo will replace that element instead of <body>?