MySQL データベースで Jquery datepicker を使用して、イベントのある日付を表示しようとしています。
好みにより、 showOtherMonths: trueを設定しました。
私がやりたいのは、現在の月にある無効な日付のスタイルを設定して、他の月の日付と同じ色にならないようにすることです。
これにスタイルを追加するにはどうすればよいですか?
$(document).ready(function()
{
var selected_dates = new Array();
// get all the events from the database using AJAX
selected_dates = getSelectedDates();
$('#datepicker').datepicker({
dateFormat: 'yy-m-d',
inline: true,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
beforeShowDay: function (date)
{
// get the current month, day and year
// attention: the months count start from 0 that's why you'll need +1 to get the month right
var mm = date.getMonth() + 1,
dd = date.getDate(),
yy = date.getFullYear();
var dt = yy + "-" + mm + "-" + dd;
if(typeof selected_dates[dt] != 'undefined')
{
// put a special class to the dates you have events for so you can distinguish it from other ones
// the "true" parameter is used so we know what are the dates that are clickable
return [true, " my_class"];
}
return [false, ""];
}
});
});