Skip to content
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

Inverted parameters in stream responses #600

Closed
letItCurl opened this issue Mar 9, 2024 · 2 comments
Closed

Inverted parameters in stream responses #600

letItCurl opened this issue Mar 9, 2024 · 2 comments

Comments

@letItCurl
Copy link

Hey everyone 👋

This:

<%= turbo_stream.update_all [@chat, :edit], @chat %>

Renders this:


<turbo-stream action="update" targets="#edit_chat_f5623fd8-6889-492f-a848-35740d3a83ef">
      ....
</turbo-stream>

The thing that tripped me is that this line turbo_stream.update_all [@chat, :edit], @chat render dom_id(:edit, @chat).
Which is inverted...

Is that intented?

@genezys
Copy link

genezys commented Mar 16, 2024

I think there is a confusion here.

The second argument to dom_id is a prefix, dom_id(:edit, @chat) is invalid and will raise an exception.

Turbo targets are rendered using the logic of dom_id so [@chat, :edit] is similar to dom_id(@chat, :edit) which will return "edit_chat_xxxx" where :edit is correctly used as a prefix. If you use dom_id in your view, you can use the same arguments in the same order in your targets.

@letItCurl
Copy link
Author

You are right I got confused I think!!

thank you for spending time on this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants