Open DennisNissen opened 6 months ago
So there is a slightly more fine-grained workaround. Rather than running initFlowbite
, you can call the specific init function for the component you need. For example, for me it was tabs.
const Hooks = {}
Hooks.FlowbiteTabs = {
mounted(){
window.initTabs();
}
updated(){
this.mounted()
}
}
Describe the bug Flowbite elements that require javascript do not work or stop working when added to the dom with a liveview
update
. This is especially uncomfortable when usingasync
data fetching and using flowbite components (f.e.Accordions
) or when you update dom elements with server pushes.Expected behavior Flowbite elements do always work, even when added to the dom with a liveview
update
.Desktop (please complete the following information):
Additional context
Example:
The
example-accordion
's content is pushed to the client after the async data loading has finished and flowbite elements in the result will not work.Liveview's dom hook has the ability to apply javascript to the dom elements that are pushed to the client with
But the
init....
(f.e.initAccordions
) functions are usingdocument.querySelectorAll()
and thus are unable to be scoped to the incoming DOM nodes.A workaround for now is to apply a custom hook to the parent node
and in the template file
This works, but triggers a lot of
init
functions for each update. It would be great to be able to apply the init functions to the dom elements that are updated.