I have one array for disabled dates and another for dates to be highlighted. Is there a way to code this?
eg:
beforeShowDay: function(date){
var unavilble = jQuery.datepicker.formatDate('yy/mm/dd', date);
var newstring = [ arrayable.indexOf(unavilble) == -1 ];
return newstring;
},
2nd array:
var datet = ['2014/01/19', '2014/01/20'];
//tips are optional but good to have
var tips = ['some description','some other description'];
function highlightDays(date) {
for (var i = 0; i < datet.length; i++) {
if (new Date(datet[i]).toString() == date.toString()) {
return [true, 'highlight', tips[i]];
}
}
return [true, ''];
}
beforeShowDay: highlightDays,
Try something like
var datet = ['2014/01/19', '2014/01/20'];
//tips are optional but good to have
var tips = ['some description', 'some other description'];
var arrayable = ['2014/01/01', '2014/01/08', '2014/01/15', '2014/01/22', '2014/01/29']
$('input').datepicker({
dateFormat: 'yy/mm/dd',
beforeShowDay: function (date) {
var datestring = jQuery.datepicker.formatDate('yy/mm/dd', date);
var hindex = $.inArray(datestring, datet);
if (hindex > -1) {
return [true, 'highlight', tips[hindex]];
}
var aindex = $.inArray(datestring, arrayable);
return [aindex == -1]
}
})
Demo: Fiddle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.