-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add turbo_frame_dom_id helper #449
Conversation
This enables being able to pass the generated id of a turbo_frame_tag to turbo_stream actions. For example: ```erb <%# app/views/articles/show.html.erb %> <%= turbo_frame_tag(Article.find(1), "comments") %> <%# app/views/comments/create.turbo_stream.erb %> <%= turbo_stream.append turbo_frame_dom_id(Article.find(1), "comments"), @comment %> ``` Using `dom_id` in this case does not work, because the turbo_frame appends additional arguments to the id while dom_id prepends them.
I'm wondering if we instead should change the way the turbo frame helper generates the ID |
I agree with @marcoroth. dom_id(@recording, :comments) #=> "comments_recording_123"
turbo-rails/app/helpers/turbo/frames_helper.rb Lines 27 to 28 in 728b963
My preference would be to change The downside, of course, is that it's a breaking change for anyone using it with multiple positional arguments and expecting a specific result. I would argue that the behavior is already broken – it's impossible to generate a /cc @afcapel, @kevinmcconnell |
Yes! This was one of the many things that took me by surprise when trying Hotwire. Had planned to open an issue but hadn't had time to do so. I agree that |
Changing to just use Something roughly like
|
I consider the current setup a bug. Should just fix to use dom_id directly. Feel free to open a PR for that. |
This enables being able to pass the generated id of a turbo_frame_tag to turbo_stream actions.
For example:
Using
dom_id
in this case does not work, because the turbo_frame appends additional arguments to the id while dom_id prepends them.