I am trying to create a datepicker that would read some variable and disable that date in that variable.
Currently following this documentation by http://t1m0n.name/air-datepicker/docs/#example-custom-content
but i can't seem to understand much about the OnRenderCell: function
how can i make it disable a specific date say july 16, 2016
onRenderCell: function (date, cellType) {
if (cellType == 'month') {
var day = date.getDay(),
isDisabled = disabledDays.indexOf(day) != -1;
return {
disabled: isDisabled
}
}
}
var disabled_months = ["2016-1-1", "2016-2-1", "2016-6-1"];
var disabled_days = ["2016-6-1", "2016-6-3", "2016-6-20"];
var disabled_years = ["2014-1-1", "2013-1-1", "2000-1-1"];
$('#datepicker').datepicker({
language: 'en',
onRenderCell: function (date, cellType) {
pretty_date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
var disabled = false
if (cellType == 'month')
disabled = disabled_months.indexOf(pretty_date) != -1
else if (cellType == 'day')
disabled = disabled_days.indexOf(pretty_date) != -1
else if (cellType == 'year')
disabled = disabled_years.indexOf(pretty_date) != -1
return {disabled: disabled}
}
});
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.