You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Turbo Stream responses in a Rails 7.2 app. On the frontend, I'm listening for events like turbo:submit-end and other Turbo Stream events. These events are fired on the global document, which is where they have to be listened to, but none of them include a reference to the initiator—the link_to helper I used with data-turbo-stream="true" to trigger the flow.
Turbo is creating a synthetic form and submitting it, and in the response, it considers that form to be the target.
In a real-world example, the page might have multiple forms and links doing different things. I can't just listen globally for turbo:stream-end and say “if success, do X” (in my case, I just want to toggle a class). Whether or not I use Stimulus doesn’t matter here (I’m still using jQuery, though I’m phasing it out). The issue is that there's no reliable way to identify which element triggered the stream, and that really limits what you can do with it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Turbo Stream responses in a Rails 7.2 app. On the frontend, I'm listening for events like turbo:submit-end and other Turbo Stream events. These events are fired on the global document, which is where they have to be listened to, but none of them include a reference to the initiator—the link_to helper I used with data-turbo-stream="true" to trigger the flow.
Turbo is creating a synthetic form and submitting it, and in the response, it considers that form to be the target.
In a real-world example, the page might have multiple forms and links doing different things. I can't just listen globally for turbo:stream-end and say “if success, do X” (in my case, I just want to toggle a class). Whether or not I use Stimulus doesn’t matter here (I’m still using jQuery, though I’m phasing it out). The issue is that there's no reliable way to identify which element triggered the stream, and that really limits what you can do with it.
Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions