简体   繁体   English

带有SQL的EventSources在Fullcalendar中不起作用

[英]EventSources with sql not working in Fullcalendar

Hello im trying to use EventSources to get multiple events in the same calendar with sql, but when I try to do it like the fullcalendar docs the calendar goes blank. 您好,我尝试使用EventSources通过sql在同一日历中获取多个事件,但是当我尝试像fullcalendar docs一样执行日历时,日历将变为空白。 What am I doing wrong? 我究竟做错了什么? Here is my code for the callendar 这是我的callendar代码

                      <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>

Your php file must return the events as a json feed, 您的php文件必须以json供稿的形式返回事件,

Example : 范例:

<?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);


?>

Adjust your php files to return json feed to the source of the calendar as shown above. 调整您的php文件,以将json feed返回到日历源,如上所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM