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 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题