I want to display a calendar with only a few dates enabled, I make an ajax request that returns an array with the date I want to enable, the function I have today is similar to this example here in Fiddle , just that the values of the array * availableDates * needs to be passed in the ajax request drop, below this my code. >
//Função para modificar a agenda de acordo com o profissional
$("#listaProfissionais").on('click', 'li a', function () {
var id = $(this).attr('id');
$.get("Agendamento/AgendaProfissional", { idFuncionario: id }, function (data) {
availableDates = data;
$("#calendario").css('display', 'block');
});
});
$(function () {
$("#calendario").datepicker({
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: "dd-mm-yy",
dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
nextText: 'Proximo',
prevText: 'Anterior',
minDate: 0,
beforeShowDay: available
});
});
var availableDates;
function available(date) {
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
if ($.inArray(dmy, availableDates) != -1) {
return [true, "", "Available"];
} else {
return [false, "", "unAvailable"];
}
}