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

is preline works with rails turbo streams ?? #541

Closed
boziad opened this issue Dec 30, 2024 · 2 comments
Closed

is preline works with rails turbo streams ?? #541

boziad opened this issue Dec 30, 2024 · 2 comments

Comments

@boziad
Copy link

boziad commented Dec 30, 2024

Summary

preline ui not working with turbo streams

Steps to Reproduce

I have this action that renders the content of the partial new inside turbo_frame with id modal,
the content of the partial is the modal example from preline ui

 render(
        turbo_stream: turbo_stream.update(
          'modal',
          partial: 'posts/new'
        )
      )

it renders correctly but the close buttons and the scroll is not working,

Demo Link

i can't provide it

Expected Behavior

modal to work with rails turbo streams

Actual Behavior

modal not working with rails turbo streams

Screenshots

No response

@lenart
Copy link

lenart commented Jan 2, 2025

I think you should take care about properly re-attaching DOM event listeners. Play with HSStaticMethods.autoInit() or call autoInit() from specific components.

@boziad
Copy link
Author

boziad commented Jan 2, 2025

@lenart Thank you for the hint, i did actualy find the solution, which is init preline after every stream render

const afterRenderEvent = new Event("turbo:after-stream-render");
addEventListener("turbo:before-stream-render", (event) => {
    const originalRender = event.detail.render
    event.detail.render = function (streamElement) {
        originalRender(streamElement)
        document.dispatchEvent(afterRenderEvent);
    }
})

document.addEventListener("turbo:after-stream-render", (event) => {
    HSStaticMethods.autoInit();
})

@boziad boziad closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants