hotwired / turbo-rails

Use Turbo in your Ruby on Rails app
https://turbo.hotwired.dev
MIT License
2.11k stars 326 forks source link

data-turbo-frame (targetting different frame) not working? #420

Open chmich opened 1 year ago

chmich commented 1 year ago

Hi there,

regarding to docs/frame-with-overwritten-navigation-targets and great hotrails-tutorial turbo-frames-and-turbo-streams i understood that just adding data-turbo-frame="different-frame" should target just to another frame.

But didnt work. What it did, was: It redirected to a completely new location, my layout was lost and i saw nothing else than the server-response.

I had to wrap the server response within a = turbo_frame_tag 'different-frame' do tag and then it worked. So, my working code is:

edit.html.haml

= turbo_frame_tag 'passwords-form-wrapper' do
  %h1
    Edit Password
  = render 'form'

=> if i remove the first line (turbo-frame-tag), above mentioned error occurs

index.html.haml

= link_to pw.title, edit_folder_password_path(@folder, pw), data: { turbo_frame: 'passwords-form-wrapper' }

Layout

The frame i want to target

 = turbo_frame_tag 'passwords-form-wrapper'

So, on that way it works but i would understand that it cannot be the aim to have to say the controller-view the target. I want just to say the link where i want to target, and not the controller. I would think it should be possible, to lead the same controller, by another link, to a different location?

is this a bug or a feature?

Rails 7.0.4 turbo-rails 1.3.2 @hotwired/turbo-rails: "^7.2.4"

Thanks, Chris

benngarcia commented 1 year ago

Also having this issue. I have a search form. When inside the turbo_frame_tag, the Turbo-Frame header is set. But when adding data: { turbo_frame: players } outside of the turbo frame tag, it no longer works.