Reload datepicker calendar with new disabled days

Reload datepicker calendar with new disabled days

Hi All,

I have a calendar on my website with disabled day which are grayed out. So far OK.
Now I added a checkbox on my website. When I check it a javascript function is called which is calculating a new set of disabled days.
My issue now is: The new set of disbale days is not implemented in my calendar.
When I paste the js-code of the calender into the function which recalculate the disable days the calendar doesn't show up at all.

Any suggestions?

This is the calendar code:

//Availability calendar
$( "#AvailCalendar").datepicker({minDate: -0, maxDate: new Date(maxyear, 11, 31), numberOfMonths: 2, showButtonPanel: false,
dateFormat: 'yy-mm-dd',
beforeShowDay: function(date) 
{
disabledDays_in = ['2021-7-15','2021-7-16','2021-7-17'];
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < disabledDays_in.length; i++) 
{
if($.inArray(y + '-' + (m+1) + '-' + d,disabledDays_in) != -1) 
{
return [true, 'ui-state-disabled', ''];
}
}
return [true, '', ''];
}
});