FullCalendar - Google日历活动颜色

时间:2011-11-22 08:24:54

标签: fullcalendar

我正在使用FullCalendar将Google日历嵌入this网页

由于Google日历活动的颜色未进入完整日历,因此我希望使用不同的背景颜色在本地设置每个活动的样式。

最简单的解决方案是为每个事件添加一个类名。我希望将事件标题生成到类名中。

我曾尝试使用ClassName,但无法使其正常运行。

希望听取有人提出建议的意见。

2 个答案:

答案 0 :(得分:1)

className必须返回JSON,因此您需要一个代理PHP / ASHX,您将调用它,将参数传递给它,它将调用Google Cal,transfomr并返回类似这样的内容。< / p>

[{"title":"News that will blow you away!","url":"news.aspx?i=1657","start":"2011-11-22T00:01:00","end":"2011-11-22T23:59:00","color":"rgb(232,157,0)","className":"data-newsevent clickable","newsEvent":"True","EventName":null,"description":null,"EventCompTypeMSP":null}]

enter image description here

  • Proxy-Req:您对代理的请求
  • Proxy-Res:您的代理人对您的回复

注意颜色,您可以使用它直接定义事件的颜色。

注意我的classNames data-newsevent并点击了,我使用jQuery来做某些特殊的点击事件 - 它们实际上并不包含任何颜色样式,但你可以这样做,你可能必须使用!important因为fullCaldner应用默认颜色。

我首先使用空Feed加载页面,然后使用客户端请求Feed,它似乎更动态,使用缓存,如果他们导航分配,它可以足够快。

答案 1 :(得分:1)

  

我希望将事件标题生成到类名中。

所以你可以像这样使用eventRender回调:

eventRender: function(event, element) {
    /**
     * @params
     * event : fullcalendar event
     * element : jQuery container
     */

     // be aware of whitespaces !
     element.addClass("fc-" + event.title.replace(/\s+/g, "_"));

}