I have a JQueryUI Datepicker with some days disabled using the beforeShowDay parameter. I know you can add a tooltip using that parameter, but I need to trigger a message to appear that says "This date may not be selected."
Is this even possible? I've tried the onSelect parameter, but that only triggers when enabled dates are selected. I've also tried giving the disabled dates a class and then adding a click event to items with that class, but it didn't seem to work either.
function unavailable(date) {
var dmy = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
if ($.inArray(dmy, formattedDates) == -1) {
return [true, ""];
} else {
return [false, '', 'Unavailable'];
}
}
$('#' + className).datepicker({
controlType: 'select',
minDate: minDate,
maxDate: maxDate,
defaultDate: maxDate,
dateFormat: 'dd M yy',
setDate: maxDate,
beforeShowDay: unavailable
});
If you need to trigger a custom tool-tip
, throw an alert
with a message or whatever here's an idea:
According to the documentation the second parameter is a CSS class:
[1]: a CSS class name to add to the date's cell or "" for the default presentation https://api.jqueryui.com/datepicker/#option-beforeShowDay
So.. add a class for disabled days called "custom-tool-tip" or whatever and setup an event listener.
$('body').on('click', '.custom-tool-tip', function(e) { // or whatever event(s) you want to listen to
alert('This date may not be selected.');
});
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.