[英]Change event colour in fullcalendar
我正在嘗試給事件加色。 它從api獲取顏色。 我已經嘗試執行此操作,但是無論我如何嘗試實現它,都無法使其正常工作。
這是我通過不同方法使其工作的兩次嘗試。
1)
<script>
$(document).ready(function(){
$("#calendar").fullCalendar({
events: "/app/calendar/cal/",
eventClick: function(event) {
window.top.location = "http://127.0.0.1:8000/app/calendar/event/" + event.id;
},
eventRender: function(event, element) {
$(element).tooltip({title: event.body});
$('.fc-content').css("background-color", "red");
}
})
})
</script>
2)
<script>
$(document).ready(function(){
$("#calendar").fullCalendar({
events: "/calendars/cal/",
url: 'http://google.com/',
eventClick: function(event) {
window.top.location = "http://127.0.0.1:8000/calendars/event/" + event.id;
},
backgroundColor: 'red',
eventRender: function(event, element) {
$(element).tooltip({title: event.body});
}
})
})
</script>
您可以指定eventColor:“#yourColor”,而無需在呈現事件中執行。
如果要更改單個事件的顏色: http : //fullcalendar.io/docs/event_data/Event_Object/#color-options
您可以使用full calendar
eventColor
屬性。
JSFiddle為所有事件提供相同的顏色屬性。
有關更多詳細信息,請檢查: http : //fullcalendar.io/docs/event_data/Event_Source_Object/
http://fullcalendar.io/docs/event_data/Event_Object/
<script>
$(document).ready(function(){
$("#calendar").fullCalendar({
events: "/app/calendar/cal/",
eventClick: function(event) {
window.top.location = "http://127.0.0.1:8000/app/calendar/event/" + event.id;
},
eventColor: '#378006',
eventRender: function(event, element) {
$(element).tooltip({title: event.body});
}
})
})
</script>
要設置事件的單獨顏色 ,請在事件數組的對象中添加backgroundColor
屬性。
JSFiddle用於單個顏色。
var events_array = [{
title: 'Test1',
start: new Date(2015, 09, 14),
tip: 'Personal tip 1',
backgroundColor: 'red'
}, {
title: 'Test2',
start: new Date(2015, 09, 15),
tip: 'Personal tip 2',
backgroundColor: 'green'
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.