Good morning. I am using Jquery UI datepicker as follows:
$(document).ready(function(){
initComponent();
});
var j = 0;
function checkDate(date) {
j++;
if (j>5 && j<10)
{
return [true, 'event',''];
}
else if (j>20 && j<25)
{
return [true, 'event2',''];
}
else
{
return [true,''];
}
}
function initComponent(){
$.datepicker.setDefaults($.datepicker.regional["es"]);
$( "#datepicker" ).datepicker({
firstDay: 1,
inline: true,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
dateFormat: 'dd-mm-yyyy',
beforeShowDay: checkDate
});
}
This code shows me the datepicker calendar with different style the dates selected with the event and event2 styles. The problem is that, once the calendar is loaded, if I select any date, the style that had been modified with beforeShowDay is deleted, leaving the default style on all days of the month. I tried with refresh on onSelect but it did not work for me. Do you know if I'm missing something or what kind of mistake I'm making?
The body of the HTML is simply:
<div id="datepicker"></div>
Thank you.