单击时如何获取FullCalendar事件的颜色

时间:2014-04-04 09:03:27

标签: jquery css fullcalendar

我正在设置Fullcalendar事件的背景颜色(http://arshaw.com/fullcalendar/docs/event_data/Event_Source_Object/),如下所示:

 eventSources: [
               {
                   events: [ 
                       {
                           title: 'Event1',
                           start: '2014-07-05'
                       },
                       {
                           title: 'Event2',
                           start: '2014-07-19'
                       }

                   ],
                   color: 'green',     
                   textColor: 'black' 
               },

当我点击事件时,我希望能够确定颜色是什么(因此我可以将其更改为其他颜色)。

我正在做以下事情而没有运气:

    eventClick: function(calEvent, jsEvent, view)
    {  
      var color1 = calEvent.color; //color1 = undefined

      var color2 = $(this).css('border-color');//color2=0,255,0 in chrome, undefined in IE
    }

如何获得首先设置的实际颜色?即在示例中它将是“绿色”。

1 个答案:

答案 0 :(得分:0)

在所有浏览器中都运行良好,但你不会得到green,而是RGB。

代码:

eventClick: function (calEvent, jsEvent, view) {
    alert($(this).css('background-color'));
}

演示:http://jsfiddle.net/IrvinDominin/Y7Dm2/