flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Datepicker loading mechanism

Open megagames-me opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. When integrating the datepicker with flowbite-svelte (and I assume must happen with other wrapper libraries too), because the loader uses the DOMContentLoaded event which doesn't get fired when clicking on normal links in SvelteKit, so rel="external" must be added to the link so DOMContentLoaded can be fired and the datepicker script can execute.

Describe the solution you'd like This would be rather easy to fix. We can keep an event listener for DOMContentLoaded, but fire our own synthetic event that is documented when DOMContentLoaded is detected. If we do this, the user can fire the synthetic event when the page is loaded. This would not be a breaking change because it would still listen for DOMContentLoaded.

Describe alternatives you've considered The script could also set a function in the window that can be called to initialize the library/search for input[datepicker]s when the user calls it.

Additional context If this gets approved, I can fix it for you guys.

megagames-me avatar Jan 22 '24 05:01 megagames-me

Hi, can I submit a PR for this?

megagames-me avatar May 06 '24 12:05 megagames-me

Hey @megagames-me,

The datepicker is now a core component of Flowbite so it can be initialized just like any other component:

https://flowbite.com/docs/components/datepicker/index.html#javascript-behaviour

Please check it out and see if this will make your example work.

Cheers, Zoltan

zoltanszogyenyi avatar Jun 27 '24 10:06 zoltanszogyenyi

Looks great, thanks!

megagames-me avatar Jun 27 '24 10:06 megagames-me