Currently, I have implemented a fullcalendar feature that displays entries for multiple users with different colored calendars. However, there seems to be an issue when dragging an entry to another date - the color reverts back to default.
Below is an example of the JSON data structure:
{
"events":[
{
"title":"tkt[14411]",
"start":"2015-07-09T06:00:00.196-0500",
"end":"2015-07-09T08:00:00.196-0500",
"id":"7",
"userID":"1",
"calColor":"#ff0000",
"className":"ticketSrc_1",
"custom":"test text here"
},
{
"title":"tkt[14412]",
"start":"2015-07-11T06:00:00.196-0500",
"end":"2015-07-11T08:00:00.196-0500",
"id":"7",
"userID":"2",
"calColor":"#ffff00",
"className":"ticketSrc_2",
"custom":"test text here"
}
],
"error":"0"
}
The code snippet responsible for adding events and changing colors based on user ID is provided below:
// Removing duplicate events
for(var i=0;i<=json.events.length-1;i++){
$('#calendar').fullCalendar("removeEvents",json.events[i].id);
}
// Setting colors for each user
$.when(
$('#calendar').fullCalendar("addEventSource",json)
).done(function(){
var cname="";
for(var i=0;i<=json.events.length-1;i++){
cname=".ticketSrc_"+json.events[i].userID;
$(cname).css("background",json.events[i].calColor);
}
});