I'm using a jQuery datepicker plugin called PickMeUp.
I have the datepicker working but can't work out how to disable dates in it. My plan is to have an array of dates that would be disabled on the datepicker calendar.
I did manage to disable one date using the documentation from a previous version of the plugin, (http://www.eyecon.ro/datepicker/), but I can't figure out how to add an array of dates to it.
jQuery
$(document).ready(function(){
var now2 = new Date();
now2.addDays(-1);
now2.setHours(0,0,0,0);
$('input#cdate').pickmeup({
position : 'right',
mode : 'range',
render: function(date) {
return {
disabled: date.valueOf() == now2.valueOf()
}
}
});
});
Update
Below is the working code. (Many, many thanks to Niloct)
$(document).ready(function(){
var arDates = [new Date("2014-02-14").valueOf(),new Date("2014-02-11").valueOf(),new Date("2014-02-09").valueOf()];
$('input#cdate').pickmeup({
position : 'right',
mode : 'range',
render: function(date) {
return {
disabled: arDates.indexOf(date.valueOf()) != -1
}
}
});
});
arDatesof Dates, each one with.valueOf()instead of the objects, what happens if you saydisabled: arDates.indexOf(date.valueOf()) != -1in last line ?var arDates = ["2014-02-14","2014-02-11","2014-02-10"];new Date("2014-02-14").valueOf()for first one. Does your calendar have time too ? Try this first.