Break out of a frame during form redirect

Agrees with this solution. I’m using same. The most annoying part is that I have to write turbo_stream.replace. WTF? why Turbo then?! I’ve been using same technique with jQuery. Why then I need Turbo :smiley:. I hope it will be changed in future Turbo versions.

1 Like

Is this still a problem in the current version of Turbo? I’m running into this same issue. I want to re-render within the turbo frame except for when I want to break out and redirect. Setting the container frame target to _top doesn’t work because it applies to every request. I was thinking it would be nice if I could change/specify the turbo frame in the response header, or something like this:

redirect_to users_path, status: :see_other, turbo_frame: "_top"

Is something like this possible?

1 Like

@andrewhavens This is exactly what I was wondering as well… have you found an answer? :smile:

@zoopzoop No, I have not found an answer yet.

This functionality is now available through turbo:frame-missing event.

See the 2 comments here at the end:

I have found a solution! The solution is to return a turbo stream with a script tag that performs a Turbo.visit: https://github.com/hotwired/turbo-rails/pull/367#issuecomment-1601733561

I ran into a similar problem and the comments and links here were helpful. I did some more digging into this and wrote up an article which has three options on how one could break out and perform a redirect. The cleanest way to do this I think is to introduce a custom Turbo stream action that does the redirect.

https://www.ducktypelabs.com/turbo-break-out-and-redirect/

1 Like

Thanks @sidk your solution works wonderfully and it seems very clean to me!