Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change an event's background color with different colors, in fullcalendar?

I'm using the last version of fullcalendar, I looked on documentation how change background color event, but I don't know how make to different events.
I need for code sample with events red, blue, green, like the following picture:

enter image description here

I see this code, on document site, but I can't to apply 2 colors:

$('#calendar').fullCalendar({
  editable: true,
  events: [{
    title: 'Teste1',
    start: new Date(y, m, d, 10, 30),
    allDay: false,
    editable: false
  }, {
    title: 'Teste2',
    start: new Date(y, m, d, 11, 40),
    allDay: false
  }],
  eventColor: '#378006'
});
like image 525
claudioprv Avatar asked Apr 14 '11 18:04

claudioprv


2 Answers

Since you are using the latest version (1.5), you can set the backgroundColor property.

{
  title: 'Teste1',
  start: new Date(y, m, d, 10, 30),
  allDay: false,
  editable: false,
  backgroundColor: '#SomeColor'
},
{
  title: 'Teste2',
  start: new Date(y, m, d, 11, 40),
  allDay: false,
  backgroundColor: '#SomeOtherColor'
}   

You can also set the textColor property if you need to change that as well.

like image 153
Brandon Avatar answered Oct 30 '22 04:10

Brandon


Use css and the className property.

<style>
.event {
    //shared event css
}

.greenEvent {
    background-color:#00FF00;
}

.redEvent {
    background-color:#FF0000;
}
</style>

<script>
$('#calendar').fullCalendar({
      editable: true,             events: [
          {
              title: 'Teste1',
              start: new Date(y, m, d, 10, 30),
              allDay: false,
                editable: false,
              className: ["event", "greenEvent"]
          },
          {
              title: 'Teste2',
              start: new Date(y, m, d, 11, 40),
              allDay: false,
              className: ["event", "redEvent"]
          }           ], eventColor: '#378006'        });
</script>
like image 11
Matt MacLean Avatar answered Oct 30 '22 06:10

Matt MacLean