简体   繁体   中英

JS Fullcalendar background color not setting

I am trying to set the background color of an event with FullCalendar JS http://arshaw.com/fullcalendar/

Here is my JS:

<script>
$('#calendar').fullCalendar({
    events: [
        {
            title: 'Test',
            start: '2014-08-07',
            url: '#',
            backgroundColor: '#FF0000',
            editable: true
        },
    ]
});
</script>

And here is what that produces

在此处输入图片说明

Why is it not producing the result I want, the event background colored as red.

You can change the backgroundColor property for your events like:

$('#calendar').fullCalendar({
    {
      title: '1',
      start: new Date(2014, 02, 25, 10, 30),
      allDay: false,
      editable: false,
      backgroundColor: '#ED1317'
    },
    {
      title: '2',
      start: new Date(2014, 02, 26, 10, 30),
      allDay: false,
      editable: false,
      backgroundColor: '#ED1317'
    },
    ...
});

For the other dates, just use the .fc-future and .fc-today CSS properties :

.fc-future,
.fc-today {
    background-color: #10CC55;
}

Updated :

$('#calendar').fullCalendar({
eventSources: [        
    {
        events: [ 
            {
                title  : 'event1',
                start  : '2010-01-01'
            },
            {
                title  : 'event2',
                start  : '2010-01-05',
                end    : '2010-01-07'
            },
            {
                title  : 'event3',
                start  : '2010-01-09 12:30:00',
            }
        ],
        backgroundColor: '#ED1317'
    }  
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM