我正在尝试在 v5 fullcalendar 中呈现一些事件。这是我的代码:
document.addEventListener('DOMContentLoaded',function(){
var cUI= document.getElementById('calendar');
var c= new FullCalendar.Calendar(cUI,{
themeSystem: 'bootstrap',
headerToolbar:{
left:'prev,next today',
center:'title',
right:'',
},
events:[
{% for v in vacation %}
{
{% if v.id_cause.cause_name == 'Vacations' %}
backgroundColor : 'blue',
borderColor : 'blue',
{% else %}
backgroundColor : 'darkgreen',
borderColor : 'darkgreen',
{% endif %}
textColor : 'gray',
title:"{{ v.startT }} - {{ v.endT }}",
start: "{{ v.startD | date:'Y-m-d' }}",
end: "{{ v.endD | date:'Y-m-d' }}",
description:"{{v.id_cause.cause_name}} {{v.cause_text}}",
},
{% endfor %}
],
{% comment %} eventDidMount: function(info) {
var tooltip = tippy('.fc-event-title-container',{
content: info.event.extendedProps.description,
placement: 'top',
interactive: true,
});
}, {% endcomment %}
});
c.render();
c.setOption('locale','en');
});
- -更新 - -
document.addEventListener('DOMContentLoaded',function(){
var cUI= document.getElementById('calendar');
var c= new FullCalendar.Calendar(cUI,{
themeSystem: 'bootstrap',
headerToolbar:{
left:'prev,next today',
center:'title',
right:'',
},
events:[
{backgroundColor : 'blue',
borderColor : 'blue',
textColor : 'gray',
title:"08:00-09:00",
start: "2021-10-13",
end: "2021-10-20",
description:"vacation- holy time"},
{backgroundColor : 'green',
borderColor : 'green',
textColor : 'gray',
title:"08:00-10:00",
start: "2021-10-15",
end: "2021-10-15",
description:"medical- future´s coming"},
],
eventDidMount: function(info) {
var tooltip = tippy('.fc-event-title-container',{
content: info.event.extendedProps.description,
placement: 'top',
interactive: true,
});
},
});
c.render();
c.setOption('locale','en');
});
---更新---它呈现日历和提示,但是它为所有事件重复相同的提示,但不同原因名称的颜色显示不同,所以我不明白它正确呈现所有事件及其数据但提示失败。我在 django 3 顺便说一句。也许使用 eventRender 回滚到以前的完整日历版本,而不是 eventDidMount?谢谢您的帮助