使用FullCalendar获取事件数据时设置自定义颜色似乎不起作用

时间:2015-05-20 23:13:56

标签: jquery-plugins fullcalendar

我正在使用FullCalendar JQuery插件并通过简单的事件数组获取事件数据。这很好,但是,我似乎无法为这些事件设置自定义颜色。我已经按照官方文档进行了操作。我究竟做错了什么?我正试着设置“颜色”。和' textColor'像黄色和黑色一样的选项:

$('#calendar').fullCalendar(

    {
        events: [
            {
                title: 'Event1',
                start: '2015-05-04'
            },
            {
                title: 'Event2',
                start: '2015-05-05'
            }
        ],
        color: 'yellow',   // an option!
        textColor: 'black' // an option!
    }
)

但是,当您访问demo link here时,您会发现它不会生效。有人能指出我正确的方向吗?有关执行此方法的官方文档是here

2 个答案:

答案 0 :(得分:1)

http://fullcalendar.io/docs/usage/州:

  

以上代码应位于页面顶部的标记中

您是否尝试将<script />代码移至页面头部?目前,您已将其保存在日历下方。

答案 1 :(得分:1)

我在当地尝试过,工作正常......

$('#calendar').fullCalendar(

{
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
     eventSources: [
    {
        events: [ // put the array in the `events` property
            {
                title  : 'event1',
                start  : '2015-05-01'
            },
            {
                title  : 'event2',
                start  : '2015-05-05',
                end    : '2015-05-07'
            },
            {
                title  : 'event3',
                start  : '2015-05-09T12:30:00',
            }
        ],
        color: 'yellow',     // an option!
        textColor: 'black' // an option!
    }

    // any other event sources...

],      
});