amsul / pickadate.js

The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
http://amsul.ca/pickadate.js
MIT License
7.7k stars 1.02k forks source link

Dynamically disabling dates with data from server as user interacts with calendar: Allow disable {from: -Infinity, to: Infinity} or Prevent cascading changes when set disable when the currently selected item object becomes disabled (for DATES) #1250

Open davibertolini opened 7 months ago

davibertolini commented 7 months ago

Dynamically disabling dates with data from server as user interacts with calendar: Allow disable {from: -Infinity, to: Infinity} or Prevent cascading changes when set disable when the currently selected item object becomes disabled (for DATES)

Our use case is the following:

I'm are obtaining data from a server every time the user is moving forward in months (listening to highlight event). In our case I am fetching the next 3 months from "today". When the user advances 2 months, I fetch the next 3 months.

The data obtained from the server is used to determine which dates in the future will be disabled. As soon as data is recovered, I disable the dates, which triggers cascading changes as per docs.

let a_closed_days = // array with dates obtained by the server
myPickadateCal.set('disable', a_closed_days);

There is a case where the data from the server will result in >3+ months dates disabled, since I'm just fetching 3 months, the calendar will change to the next enabled date, with is the first day of the 4th month.

But this is not accurate, since that day is also disabled (but the calendar does not "know" it since I just fetched data for 3 months).

I tried these solutions:

But none seem to work. Maybe there will be no response as this project is seems to be deprecated in lieu of V5, but still worth the try. Willing to bounty this to the problem solver.

Thank you.