简体   繁体   中英

Fullcalendar recurring event exclusion

I'm using fullcalendar with drag-drop external events and json data source. 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). 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. I have included a custom property (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. Then, at the eventRender you will loop through this array to see if you need to exclude the event for any given day.

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;
    }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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