排除全日历重复事件

Fullcalendar recurring event exclusion

本文关键字:事件 日历 排除      更新时间:2023-09-26

我使用fullcalendar与拖放外部事件和json数据源。默认情况下,这些事件每周重复一次。

我现在想添加功能,使用户能够删除这个重复事件的单个实例(就像在google日历中一样)。我认为这将需要某种机制来从重复事件中排除某个事件日期。

我在完整的日历文档中找不到任何支持这种开箱即用的行为的东西。

我更喜欢客户端解决方案。

我创建了一个jsfiddle,它展示了如何显示除一个日期外的每日并发事件。我包含了一个自定义属性(exclusideddate)。在您的解决方案中,需要包含一个名为excludedDates的属性,该属性包含日期数组,每次要删除单个实例时,只需将日期添加到该属性数组中。然后,在eventRender中,你将循环遍历这个数组,看看你是否需要在任何给定的日子里排除事件。

eventRender: function(event, element, view) {
    var theDate = event.start
    var excludedDate = event.excludedDate;
    var excludedTomorrrow = new Date(excludedDate);
     //if the date is in between August 29th at 00:00 and August 30th at 00:00 DO NOT RENDER
    if( theDate >= excludedDate && theDate < excludedTomorrrow.setDate(excludedTomorrrow.getDate() + 1) ) {
        return false;
    }
    }