-
Notifications
You must be signed in to change notification settings - Fork 436
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
None of the Turbo events are not triggered on 422 #520
Comments
Would listening for a turbo:before-stream-render event suit your use case? |
If you're on Stimulus v3, you have access to target connection callbacks, which could help you avoid event listening entirely. If your Stimulus controller is high-enough in the page's hierarchy, you could annotate elements with This avoids event listeners, page visits vs. Turbo Streams, etc because Stimulus manages the plugin entirely based on whether or not the element is present or absent in the document. |
Thanks for your reply. It's very appreciated ! The event turbo:before-stream-render is indeed called but loading plugins from there doesn't work. Probably if I use a setTimeout(() => { ... }, 1000) that would work but I find it ugly. I went ahead and gave a try to your method:
Append to all my select I would be happy with this solution, but there is one thing that bothers me and is doing this to my body (It's HAML)
If I have multiple libraries that would get ugly, I would then need to do this:
Isn't there a better way? |
The data- attributes that power Stimulus accept token lists, so you can add controller identifiers or action descriptors as lists separated by spaces. |
You mean that
would be valid? |
That's right! The same is true for |
Thank you I didn't know! Thanks for all the quick replies. Very appreciated. I'm closing the issue |
The solution of Additionally, I found this wrapper that works great particularly for tom-select: |
Hi,
Kind of reopening #85
When you have form errors and render it using turbo streams
None of the Javascript events are triggered making impossible to load libraries such as Tom-Select or Bootstrap custom calendars.
Some people recommends to add data-controller attribute and use stimulus controller, but none of them show how to properly do it when you have many input you want to trigger or that maybe you already call another controller on the same input.
What are the proper workaround ?
Thank you
Edit
A dirty workaround would be
but keep in mind that javascript inside turbo-frame will still not reload on frame update
The text was updated successfully, but these errors were encountered: