All threads / Hotwire prevents link_to from going to a different website

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Hotwire prevents link_to from going to a different website

Fatumata Jalloh asked in General

I recently added Hotwire to my rails app to update modals but this broke a link_to I had that redirected users to stripe. I looked online for ways to work around it but since Hotwire is relatively new, I couldn't find it. Does anyone have any recommendations on getting link_to to work with turbo stream?

Use target="_top" as shown in https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb:
<%= turbo_frame_tag "tray", src: tray_path(tray), target: "_top" %>
The issue is that Turbo Frames hijacks links as described quite well here: https://blog.cloud66.com/taking-rails-to-the-next-level-with-hotwire/

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 52,887+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.