你好,我试图使用EventSources用sql在同一日历中获取多个事件,但当我尝试像fullcalendar文档一样这样做时,日历会变为空白。我做错了什么?这是我的被叫代码
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() { // DOMContentLoaded zorgt ervoor dat eerst de html laad
var calendarEl = document.getElementById('calendar'); // grab element reference
var calendar = new FullCalendar.Calendar(calendarEl, {
// Opties in fullcalendar
eventLimit: true,
locale: 'nl',
buttonText: {
month: 'Maand',
agendaDay: 'Dag',
agendaWeek: 'Week',
today: 'Vandaag',
listMonth: 'Lijst'
},
header: {
left: 'prev,next today',
center: 'title',
right: 'listMonth,month,agendaWeek,agendaDay'
},
eventSources: [
'/sql.php',
'/availability.php'
]
});
calendar.render();
});
</script>
php文件必须以json提要的形式返回事件
示例:
<?php
$event_array = array();
while ($row = $getCalenderItems->fetch()) {
$event_array[] = array(
"title" => $row['Docentnaam'] . ' ' . $row['Onderdeelnaam'] . ' ' . $row['Opleidingnaam'] . ' ' . $row['LocatiePlaats'],
"start" => new Date($row['Start']),
"end" => new Date($row['Eind'])
);
}
echo json_encode($event_array);
?>
如上所示,调整php文件以将json提要返回到日历源。