wakirin / Litepicker

Date range picker - lightweight, no dependencies
MIT License
899 stars 132 forks source link

A way to only allow days from list (allowDays) #177

Closed PlippiePlop closed 3 years ago

PlippiePlop commented 3 years ago

With lockDays you can insert a list or range where the parsed days will be locked / excluded: lockDays: [['2021-02-08', '2021-02-28'],['2021-03-8','2021-03-31']],

But what if you have a calendar where you're only allowed to select a few days or ranges per month? The lockDays list would be huge if you want to have this on a whole year or spanning several months.

Imho its much easier to do allowDays: You disable the whole calendar and only allow days which are in the given list. AllowDays: [['2021-02-01',2021-02-07],[' 2021-03-01','2021-03-07']]

Maybe this is already there, but i could not find it in the documentation.

Is there a function method avalable for lockDays? lockDays: function(e){...}

wakirin commented 3 years ago

I think you can do it with lockDaysFilter

PlippiePlop commented 3 years ago

I found a solution to disable all days and only enable days from a list provided by for example a database.

See my fiddle here.

wakirin commented 3 years ago

@PlippiePlop Thanks for sharing the solution!

As I said, you can also use lockDaysFilter.

https://jsfiddle.net/56oamcd0/

PlippiePlop commented 3 years ago

Thanx Wakirin, this sort of examples should be in the demo(s). The doc is a bit unclear how to do some things.