mymth / vanillajs-datepicker

A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks
MIT License
720 stars 147 forks source link

how onclick event and get date clicked #116

Open woxman opened 1 year ago

woxman commented 1 year ago

please help , i can get clicked date

mymth commented 1 year ago

Your code in https://github.com/mymth/vanillajs-datepicker/issues/20#issuecomment-1186140439 seems to work if the showMessage() function is in global scope.

I think using event delegation like this: https://codepen.io/mymth/pen/mdxRWqB would be safer.

BorjaRafolsMartinez commented 1 year ago

You have to listen to the changeDate event, lost a fair amount of time because I was looking for the standard input onChange event.

datePickerInput.addEventListener('changeDate', onChange)

JoshuaAlzate commented 1 year ago

I am getting Property 'addEventListener' does not exist on type 'Datepicker'.

BorjaRafolsMartinez commented 1 year ago

You have to call it on the input, not the DatePicker instance