-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Any JS based component not working with Hotwired Turbo #1703
Comments
Hi! Did you solve the problem? |
I've ended up with a custom event listener
|
So I found the issue. As Turbo does not reload the full page but replaces the body from the response in the XHR.
I figured out also that I needed to add import {Collapse, Dropdown, initTE, Input, Ripple, Toast, Sidenav,} from "tw-elements";
const initTailwindElement = () => {
// Reset the initiatedComponents array on turbo:load
initiatedComponents.splice(0, initiatedComponents.length)
initTE({Input, Ripple, Dropdown, Collapse, Toast, Sidenav,});
}
document.addEventListener("turbo:load", initTailwindElement) Now with the rewrite with the Wdyt @smolenski-mikolaj ? |
So I found that we can use the v1.0.0 that has this nice fix: https://github.com/mdbootstrap/Tailwind-Elements/pull/1919/files Thank you! |
Hi @makikata , the v1.0.0 is going to be released on monday, 11.09.2023 |
@juujisai is this bug fixed? 2023-09-20.4.47.25.movcode
Any suggestion? |
@ponponwu Try adding options to
|
Hi @juujisai , but if I go to previous page then next page, this situation may happens |
Hi @ponponwu. Without the Maybe wrapping the
Other think I can think of is to
|
@juujisai thanks again for your time! |
@ponponwu I listen to
|
This worked well for me. import { Select, initTE } from "tw-elements";
addEventListener("turbo:load", event => {
initTE({ Select })
})
addEventListener("turbo:frame-render", event => {
initTE({ Select }, { allowReinits: true })
})
import '@hotwired/turbo-rails' |
I ended up using stimulus to solve this
thanks everyone! |
I tried all above solutions and for some reason the selects and inputs were still breaking for me, but I could fix them with the following code: import { Dropdown, Collapse, Select, Input, Ripple, initTE } from "tw-elements";
initTE({ Dropdown, Collapse, Ripple })
addEventListener("turbo:load", event => {
document.querySelectorAll("[data-te-select-init]").forEach((el) => {
new Select(el);
})
document.querySelectorAll("[data-te-input-wrapper-init]").forEach((el) => {
new Input(el);
})
}); |
Hi, i'm using unpoly with tw-elements and faced similar issue.
|
HI @vb8448, keep in mind some components have their callbacks which are required for proper initialisation. We recommend using the |
@iprzybysz I wasn't able to make I guess I can update a little bit the
|
We also think about something similar to what you suggest. We may add it in the future. |
When it installed on top of Hotwire (Turbo) the JS getting broken due to import of tailwindcss-element into tailwindcss.config is by node module path specific not global initializer
import {
Datepicker,
Input,
initTE,
} from "tw-elements";
initTE({ Datepicker, Input });
The text was updated successfully, but these errors were encountered: