Is It Possible To Assign The Background Colour Of A Fullcalendar Event Based On Its Title?
As FullCalendar isn't able to read the colours that are assigned to events in Google Calendar I need to be able to style the way events are displayed based on the text content of t
Solution 1:
in the eventRender callback
if(-1 != event.title.indexOf("blah blah")) {
element.find('.fc-title').css('background-color', '#ff000');
}
will do it.
or better yet, apply a style element.addClass("event-bg-class");
Solution 2:
Did you basically try ?
if(-1 != event.title.indexOf("blah blah")) {
element.css('background-color', '#ff000');
}
Solution 3:
# Hope it'll help you
element.addClass("custom-event-0");
element.addClass("custom-event-1");
$(document).ready(function() {
var eventsdata = [];
var i = 0;
$('#calendar').fullCalendar({
height: 'auto',
header: {
left: 'prev,next today',
center: 'title',
right: 'agendaDay,month',
},
eventRender: function(event, element) {
if(event.description == "blah blah") {
element.css('background-color', '#ff000');
}
},
// Google API keygoogleCalendarApiKey: 'xxxxxxxxx',
// Diary Datesevents: 'xxxxxxxxx',
eventRender: function(event, element) {
if(eventsdata.length == 0){
eventsdata.push(event.title);
i++;
}else{
var tmp = eventsdata.indexOf(event.title);
if(tmp == -1){
eventsdata.push(event.title);
i++;
}
}
element.addClass("custom-event-"+eventsdata.indexOf(event.title));
},
eventClick: function(event) {
// opens events in a popup windowwindow.open(event.url, 'gcalevent', 'width=700,height=600');
returnfalse;
},
loading: function(bool) {
$('#loading').toggle(bool);
}
});
Post a Comment for "Is It Possible To Assign The Background Colour Of A Fullcalendar Event Based On Its Title?"