对于一个小项目,我想在运行时添加事件。
实际的日历是使用数据库中的数据创建的。单独的脚本创建其他事件,这些事件是在日历运行时动态创建的。这些事件随后应添加到现有日历中。
为了进行测试,我有一个日历和一个外部按钮。如果单击该按钮,则会将事件添加到日历中。创建日历并识别单击。但没有添加任何事件。
思想错误在哪里?
超文本标记语言
<button class="holiday">Add Feiertage</button> <div id='calendar'></div>
代码:
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek'
},
initialDate: '2020-11-12',
businessHours: true, // display business hours
editable: true,
events: [
{
title: 'Business Lunch',
start: '2020-11-03T13:00:00',
constraint: 'businessHours'
},
{
title: 'Meeting',
start: '2020-11-13T11:00:00',
constraint: 'availableForMeeting', // defined below
color: '#257e4a'
},
{
title: 'Conference',
start: '2020-11-18',
end: '2020-11-20'
},
{
title: 'Party',
start: '2020-11-29T20:00:00'
},
// areas where "Meeting" must be dropped
{
groupId: 'availableForMeeting',
start: '2020-11-11T10:00:00',
end: '2020-11-11T16:00:00',
display: 'background'
},
{
groupId: 'availableForMeeting',
start: '2020-11-13T10:00:00',
end: '2020-11-13T16:00:00',
display: 'background'
},
// red areas where no events can be dropped
{
start: '2020-11-18',
title: 'Test-Holiday',
overlap: false,
display: 'background',
color: '#ff9f89'
}
]
});
calendar.render();
});
这是我的测试: https: //jsfiddle.net/LukasHH/tu14xfwr/
偶然的你
相关分类