So, I have the days loaded in calendar with solution from my previous question
code here for clarity
$("#datepicker").datepicker({
firstDay: 1,
dateFormat: "yy-mm-dd",
minDate: minDate,
beforeShowDay: function (date) {
var month = (date.getMonth() + 1).toString().padStart(2, "0");
var year = date.getFullYear();
var day = date.getDate().toString().padStart(2, "0");
// Change format of date
var newdate = year + "-" + month + '-' + day + 'T00:00:00';
// Check date in Array
if (jQuery.inArray(newdate, unavDates) != -1) {
return [true, "available"];
}
else{
return [false, "unavailable"];
}
if (date.getDay() === 0 || date.getDay() === 6 || date.getDay() === 1 || date.getDay() === 5){
return false;
}
return [true];
},
});
but the problem I have is that the function is triggered by a click on a day in calendar. How do I make it available on page load?