简体   繁体   English

全日历重复事件排除

[英]Fullcalendar recurring event exclusion

I'm using fullcalendar with drag-drop external events and json data source. 我正在将fullcalendar与拖放外部事件和json数据源一起使用。 These events repeat weekly by default. 默认情况下,这些事件每周重复一次。

I want to now add functionality that enables a user to delete a single instance of this repeating event (like in google calendar). 我现在想添加功能,使用户可以删除此重复事件的单个实例(例如在Google日历中)。 I believe this will require some sort of mechanism to exclude a certain event date from a repeating event. 我相信这将需要某种机制来从重复事件中排除某个事件日期。

I wasn't able to find anything in the fullcalendar documentation that would support this sort of behaviour out-of-the-box. 我无法在完整日历文档中找到任何可以支持这种行为的现成方法。

I would prefer a client-side only solution to this. 我希望有一个仅客户端解决方案。

I have created a jsfiddle that shows how to display a daily concurrent event with the exception of one date. 我创建了一个jsfiddle ,它显示了如何显示除一个日期之外的每日并发事件。 I have included a custom property (excludedDate). 我包括一个自定义属性(excludedDate)。 In your solution, you will need to include a property called, say, excludedDates which contains an array of dates, and every time you want to delete a single instance you just add the date to this property array. 在您的解决方案中,您将需要包括一个名为excludedDates的属性,该属性包含一个日期数组,并且每次您要删除单个实例时,只需将日期添加到此属性数组中即可。 Then, at the eventRender you will loop through this array to see if you need to exclude the event for any given day. 然后,在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;
    }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM