I am using fullcalendar and I am looking for a way to pass background color as an event
so that my calendar app can use a combination of colored events and colored backgrounds.
I'm pretty sure this is not supported by the library, so if anyone has any notes towards coding the feature or experience working with the code, that would be helpful.
The following question is very similar to mine, but not written clearly enough to know if it's a dupe:
Fullcalendar event cell background color
Update 1
Based on the accepted answer, I use the following event specs
{
title: '',
start: moment().add(2,'h').toISOString(),
end: moment().add(5,'h').toISOString(),
color: 'rgba(63, 191, 191, 0.24)',
textColor: 'rgba(63, 191, 191, 0)',
editable: false,
durationEditable: false,
allDay: false,
fakeEvent: true
},
{
title: 'WORK DAY',
start: moment().add(1,'h').toISOString(),
end: moment().add(3,'h').toISOString(),
color: 'green',
//background-color = 'blue'
},
And get this result. Next step is trying to prevent the event overlapping display algorithm, so that the light blue appears more like a background color, less like an event.
Update 2
I have since discovered this example app that accomplishes what I needed: http://fullcalendar.io/js/fullcalendar-2.2.0/demos/background-events.html
Best Answer
That question you referenced isn't the same. He was looking to change the background color of any day that has an event, not the event itself. What you are trying to do is supported by the library. You can set the color of the event by passing in a
color
property with the event data.All examples can be found on the FullCalendar Event Source Object page. As noted on that example page, you can set it in the array of events:
or in JSON:
Now, those are setting the background for every event in the source, but you can do it per event as well, the same way, like:
You can use
eventColor
andeventTextColor
(src) to set the background for all events on the calendar, likeAfter further clarification it appears you want certain time slots to have colors but not be a "real" event. You can do this in FullCalendar 2.2 using the
Background Events
by addingrendering: 'background'
to the event (documentation).