删除当前月份的过去日期和下个月日期

rub*_*ist 20 jquery fullcalendar

是否可以从完整日历中删除过去的日期和下个月的日期?因此,对于当前月份,它应仅显示当前日期和日期.

小智 16

您可以尝试在eventRender()方法中跳过事件:

eventRender: function(event, element, view)
{
   if(event.start.getMonth() !== view.start.getMonth()) { return false; }
}
Run Code Online (Sandbox Code Playgroud)


小智 8

下个月和上个月的网格单元格具有"fc-other-month"类,因此您可以通过以下方式定位它们:

例如:隐藏日期编号,添加CSS:

.fc-other-month .fc-day-number { display:none;}
Run Code Online (Sandbox Code Playgroud)

或运行此JavaScript:

$(".fc-other-month .fc-day-number").hide()
Run Code Online (Sandbox Code Playgroud)


Moh*_*han 6

试试这个!

$('.fc-other-month').html('');
Run Code Online (Sandbox Code Playgroud)

这适合我!


Zet*_*eek 5

此答案中提供的解决方案都无法正确解决当前版本的 FullCalendar 的问题。以 Bascht 的答案为起点,我更新了他的方法以使用当前的 FullCalendar API。下面是完成此任务的工作示例代码:

eventRender: function (event, element) {
    var eventDate = event.start;
    var calendarDate = $('#activitiesCalendar').fullCalendar('getDate');
    if (eventDate.get('month') !== calendarDate.get('month')) {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 这应该是正确的答案 - 感谢您发布此内容! (2认同)

Kih*_*ats 5

添加此设置showNonCurrentDates: false。使用此设置,将不会显示不属于当月的日期和事件。

$('#calendarId').fullCalendar({
     // Other settings
     showNonCurrentDates: false            
});
Run Code Online (Sandbox Code Playgroud)