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

There should be a way to re-initialize a single Datepicker element #821

Open
lobot1010 opened this issue Feb 28, 2024 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@lobot1010
Copy link

lobot1010 commented Feb 28, 2024

Is your feature request related to a problem? Please describe.
I'm using HTMX to load content into the page dynamically. Some of this dynamic content consists of Datepicker inputs. When these inputs enter the DOM, the DOMContentLoaded event is NOT fired, so initDatepickers therefore doesn't run.

To get around this, I can manually wire up an event listener to HTMX content being loaded and run initDatepickers. However this re-initializes ALL the datepickers on the page when I would like to re-initialize them ad-hoc.

Describe the solution you'd like
It would REALLY help if you added an initDatepicker(elementId: str) method that can be used in these ad-hoc cases. This would make re-initializing date pickers much easier.

Describe alternatives you've considered
From the docs, it seems like Flowbite wants us to use the Javascript API to create Datepicker objects for these ad hoc. I am unable to do that using the minified JS file (there's no Datepicker constructor available for use). I'm using Flowbite in the context of Django templates without NPM and have no plans to set up Webpack in Django.

Additional context
Appreciate your time

@lobot1010
Copy link
Author

lobot1010 commented Feb 29, 2024

Follow up question - is there a reason why the Datepicker object isn't exported and available for use from the minified JS file? This is rather different than the API provided by the rest of Flowbite. I'm able to use the Modal constructor, why not the Datepicker?

Is the recommended alternative to use the datepicker-full.js file to get access to the full API?

@zoltanszogyenyi
Copy link
Member

Hey @lobot1010,

Working on this feature now: https://github.com/themesberg/flowbite/tree/datepicker-instance

Cheers,
Zoltan

@zoltanszogyenyi zoltanszogyenyi added the enhancement New feature or request label May 8, 2024
@zoltanszogyenyi zoltanszogyenyi self-assigned this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants