拔掉我留在这里的一点点头发,试图按照 js fullcalendar 控件上的文档来更改单个事件的背景。
我在这里关注了其他几个主题,例如 Adding nice colors to events in FullCalendar (jquery)和 fullcalendar backgroundColor property这都建议我设置事件的属性 backgroundColor,或者设置一个类并将其附加到事件,所有这些都将被忽略。
我唯一可以设法改变的是如果我设置事件的颜色属性,它将边框颜色更改为套件(根据文档,应该设置整个事件的颜色)。
我正在设置这些属性,因为我将它们推送到要传递给日历的事件数组中,如下所示
events: function(start, end, callback) {
var events = [];
reqEvents = Requests.find();
reqEvents.forEach(function(evt){
event = {id:evt._id,title:evt.title,start:evt.start,end:evt.end,color:evt.color};
event.className = 'todo';
events.push(event);
})
callback(events);
console.log(events);
},
这是在模板渲染函数中。
我试过用 event.backgroundColor = 'green' 代替 className,我试过内联这样做,我试过几乎所有我能在文档中找到的颜色命名事件,但没有任何改变背景或文字颜色。
想法??
最佳答案
不幸的是,这不是您的问题,而是 fullcalendar 为 meteor 打包的方式的错误。
正如您在 https://github.com/priyadarshy/meteor-fullcalendar/tree/master/css 中看到的那样包括屏幕和打印样式表,以及 meteor 打包 CSS 的方式将它们捆绑在一起。
不幸的是,打印样式表覆盖了所有背景。
事实上在这个文件上https://github.com/priyadarshy/meteor-fullcalendar/blob/master/css/fullcalendar.print.css它指出
Include this stylesheet on your page to get a more printer-friendly calendar. When including this stylesheet, use the media='print' attribute of the tag. Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
你可以做的是克隆这个 repo,然后删除打印 css 或者用
包围打印 css@media print {
/* print css goes here */
}
关于javascript - meteor 和事件背景颜色的 pretty-fullcalendar 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21984887/