qodesmith / datepicker

Get a date with JavaScript! A datepicker with no dependencies.
344 stars 101 forks source link

Disabled property does not work #133

Open jvlobo opened 1 year ago

jvlobo commented 1 year ago

According to the documentation, there is a property called disabled for disabling the entire calendar -> https://github.com/qodesmith/datepicker#disabled

I've tried to use it but it doesn't seem to be working. Here I tried to do it on the sandbox.js file of this repository:

https://user-images.githubusercontent.com/5671420/204535253-8846e988-2e24-43de-a168-1cec79771ace.mov

Am I missing something or it is actually an issue?

Thank you!

qodesmith commented 1 year ago

So this is admittedly confusing. Don't pass the disabled property to the options. Rather, add it to the picker instance like this:

window.single = datepicker('input', {alwaysShow: 1})

// Now add the property to the instance.
window.single.disabled = true

I don't remember why I didn't just pass on the disabled property to the instance, but for now this should work.

jvlobo commented 1 year ago

Thanks for the quick reply.

So, what it does, it does not show the calendar when you click the input, right? I thought it would still show it but with everything disabled (not clickable and with different colors to show it is disabled)

qodesmith commented 1 year ago

Yea, I saw that in the code recently too. I'm looking to give the library a complete rewrite. Ideally, the disabled property should be passed into the options at declaration time and it should just disabled the calendar functionality, but still let you show / hide it. That will take me a bit of time as I'm trying to figure out some TypeScript things.