Hi all,
I’m using turbo streams on a regular get request, how can I prevent turbo from changing the url? Or do I need to wrap the link with a frame?
i.e.
In view:
<%= link_to “Toggle”, toggle_platform_path(platform) %>
In controller:
def toggle
respond_to do |format|
format.turbo_stream
end
end
if you’re using turbo stream template responses you dont need to wrap anything, could you show a bit of your controller, turbo-stream template or something else ?
n4cr
January 18, 2021, 8:19am
3
I guess you need to do XHR when you want to do a get for turbo stream.
dixpac
January 25, 2021, 11:51am
4
You have 2 options:
Use button_to
insted of link_to
button_to "Toggle", toggle_platform_path(platform), method: :get
Implement Stimulus Controller and pass text/vnd.turbo-stream.html
as as MIME type
Could you elaborate more on setting the mime type via a stimulus controller, thanks
@dixpac The button_to didn’t work, it issues a regular HTML (not a TURBO STREAM) request