有没有办法让月份视图中的月份值可以像谷歌日历一样点击?
我希望当用户点击一个月中的某一天(只是天数而不是整个块)时,fullCalendar会切换到该特定日期的日视图.
谢谢!
Mat*_*all 33
使用dayClick事件,changeView方法和goToDate方法.
像这样的东西(未经测试):
$('#calendar').fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
if (allDay) {
// Clicked on the entire day
$('#calendar')
.fullCalendar('changeView', 'agendaDay'/* or 'basicDay' */)
.fullCalendar('gotoDate',
date.getFullYear(), date.getMonth(), date.getDate());
}
}
});
Run Code Online (Sandbox Code Playgroud)
您可以event.target在回调中查看:
$('#calendar').fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
if (allDay) {
// Clicked on the entire day
if ($(jsEvent.target).is('div.fc-day-number')) {
// Clicked on the day number
$('#calendar')
.fullCalendar('changeView', 'agendaDay'/* or 'basicDay' */)
.fullCalendar('gotoDate', date.getFullYear(), date.getMonth(), date.getDate());
}
}
}
});
Run Code Online (Sandbox Code Playgroud)