Rajavel D Rajavel D - 1 month ago 12
Javascript Question

What is the value initialized with "date" parameter in date-picker's beforeShowDay function?

What is the value initialized with "date" parameter of function on

beforeShowDay
?

$('#selector').datepicker({
beforeShowDay: function(date) {
if (date == myDate) {
return [true, 'css-class-to-highlight', 'tooltipText'];

}
}
});


What is the starting and ending value of date parameter in
beforeShowDay
?

Is it taking based on current date or
minDate
,
maxDate
?

Answer

The beforeShowDay is called for each day showed in the calendar... so in a month view... the method is called for each date in the month.

You can just log the value of date in the callback to see how it is called

jQuery(function ($) {
    $('#selector').datepicker({
        beforeShowDay: function (date) {
            console.log(date);
            return [true];
        }
    });
});

Demo: Fiddle