dqp99585 2013-07-16 11:45
浏览 62
已采纳

FullCalendar - 渲染JSON源

I've seen many post about fullcalendar here but none did solve my problem. I'm trying to load events from an external php file (JSON feed). Events aren't rendered in the calendar.

So here is my javascript code:

<script>
    $(document).ready(function() {

        var calendar = $('#calendar').fullCalendar({
            defaultView: 'agendaWeek',
            allDaySlot: false,
            minTime: 8,
            maxTime: 17,
            defaultEventMinutes: 30,
            weekends: false,
            selectable: true,
            selectHelper: true,
            select: function(start, end, allDay) {
                if (confirm("Voulez-vous réserver cette période?")) {

                    $('#idMedecin').val('<?php echo $_SESSION["idMedecin"]; ?>');
                    $('#idPatient').val('<?php echo $patient->numero; ?>');
                    $('#eventS').val(start);
                    $('#eventE').val(end);

                    $('#calendarForm').submit();

                }
            },
            events: {
                url: 'calendrier-feed.php',
                type: 'POST',
                data: {
                    idMedecin: '<?php echo $_SESSION["idMedecin"]; ?>'
                },
                error: function() {
                    alert('there was an error while fetching events!');
                }
            }

        });

    });
</script>

<div id="calendar">

</div>

And this is what I have in my calendar-feed.php:

getAllEvents($doc);

foreach($liste as $event) {

    $event_arr = array();
    $event_arr['id'] = $event->id;
    $event_arr['title'] = $event->patient;
    $event_arr['start'] = $event->start;
    $event_arr['end'] = $event->end;

    array_push($return_arr, $event_arr);

}

echo json_encode($return_arr);

?>

The JSON output looks like this:

[{"id":"22","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 08:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 08:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"},{"id":"23","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 09:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 09:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"}]

I'm totally clueless. Please help.

Thanks

  • 写回答

3条回答 默认 最新

  • dongzhi5386 2013-07-17 01:27
    关注

    Found a fix. I had to add this to my calendar-feed.php:

    $event_arr['allDay'] = false;

    Even tho it's "optional" in fullCalendar API, I still had to include it.

    I first thought the date was the issue but it made no sense because I'm capturing the date from the select event in a string and stuff it into a varchar in mysql.

    Anyway, problem solved :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体