Im using FullCalendar 4, and I'm importing events from my google calendar. I want these to display in the calendar as full day background events to just show that I'm busy rather than display what the event is, and how long it goes on for. Importing events and displaying them normally works fine.
I've tried using EventRender to change the rendering property as follows
eventRender: function(info) {
info.event.setProp( rendering, 'background' );
}
That seems to destroy the event and displays nothing, when I try to access the event after updating to log the start date I get the following.
Failure parsing JSON {message: "Failure parsing JSON", xhr: XMLHttpRequest}
Doing that prior to the setProp call outputs the date correctly.
I noticed in the docs that when using EventRender 'The function can also return a brand new element that will be used for rendering instead. For all-day background events, you must be sure to return a <td>
.'
I can't find any examples of how to do this in the new docs or examples though?
I've also tried to create a for each loop in both EventsRender and DatesRender to pull back all the events, and create a new background event for each existing event, then destroy the existing. This doesn't really seem to work though. When done in EventsRender I get a permanent loop as the function info.event.remove();
never seems to work. In DatesRender I get a new background event, but only on the second rendering of a month, and it doesn't delete the existing. See below for my DatesRender code.
datesRender: function(info) {
//now recreate events so they are all background events
var events = calendar.getEvents();
console.log("Dates Render!");
$.each(events, function( index, event ) {
//get event date
var date = event.start;
console.log(date);
//remove original event
event.remove();
//add new as a background event
calendar.addEvent({
title: 'dynamic event',
start: date,
allDay: true,
rendering: 'background',
backgroundColor: '#B2B2B2'
});
});
},
I'm obviously doing something dim. Can anyone point me in the right direction?
UPDATED
As suggested you can use the eventDataTransfer method to do this really simply!
eventDataTransform: function(eventData) {
eventData.rendering = 'background';
},