themesberg / flowbite-datepicker

A Tailwind CSS datepicker built with vanilla JavaScript
https://flowbite.com/docs/components/datepicker/
MIT License
137 stars 41 forks source link

Firing change event #22

Open justinperkins opened 11 months ago

justinperkins commented 11 months ago

Currently when the date value is assigned, no change event is fired, which means that when you've got custom event listeners for change events, they won't fire when a date in the picker is chosen.

xirukitepe commented 6 months ago

Hi @justinperkins

Did you manage to get this working? 🤔

justinperkins commented 5 months ago

Did you manage to get this working? 🤔

I did actually, through looking at the Flowbite datepicker source code I found that a custom event is emitted on the related input control, so you can use that to trigger custom code when a date is chosen.

Basically, if you observe for the changeDate event on your input, it will be fired when a date is chosen in the Flowbite datapicker UI.

Related Flowvite JS here: https://github.com/themesberg/flowbite-datepicker/blob/658b8cc5b84aec732e60f59044b35d4769c00294/js/Datepicker.js#L110 And here: https://github.com/themesberg/flowbite-datepicker/blob/master/js/events/functions.js#L4