Reputation: 653
I have used the BeforeShowDays method to disable days on page load for my datepicker in the past. What I would like now is to click on a day, and the day should become disabled (not clickable, as if I used the BeforeShowDays method on that day).
Is there a way to accomplish this?
Upvotes: 0
Views: 179
Reputation: 65264
var disabledDates = [];
$("#datepicker").datepicker({
onSelect: function(dateText, inst) {
disabledDates.push(dateText);
},
beforeShowDay: editDays
});
function editDays(date) {
for (var i = 0; i < disabledDates.length; i++) {
if (new Date(disabledDates[i]).toString() == date.toString()) {
return [false];
}
}
return [true];
}
Upvotes: 1