FullCalendar在日期更改时不更新事件

时间:2014-11-25 18:02:24

标签: javascript jquery fullcalendar google-calendar-api

这可能非常简单,而且我可能几乎有解决方案,但我感到非常寒冷,我的大脑也在失火。

问题:在月视图中,当我点击下一个/上个月时,该月的事件未加载;例如,当日历填充时,它会显示11月的事件。如果我点击下一个查看12月,则12月的事件不会呈现。我正在使用Google日历作为活动来源。代码如下。

$(document).ready(function(){

    $("#teenCal").fullCalendar({
        aspectRatio: 1.5,
        googleCalendarApiKey: 'AIzaSyCnfBoDwvGDCIfltN7P_ys-5MW5GGIYq8Q',
        events: { googleCalendarId: 'gchrl.org_2jguin31a4ac76bpbri5dq6jb4@group.calendar.google.com',
               backgroundColor: 'purple',
               borderColor: 'purple' },
        header: { left: 'prev',
                  center: 'title',
                  right: 'next' },
     });    
});

HTML:

<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<link media="print" href="http://examplesite.com/resources/fullcalendar/fullcalendar.print.css" rel="stylesheet">
<script src="http://examplesite.com/resources/fullcalendar/lib/moment.min.js"></script>
<script src="http://examplesite.com/resources/fullcalendar/lib/jquery-ui.custom.min.js"></script>
<script src="http://examplesite.com/resources/fullcalendar/fullcalendar.min.js"></script>
<script src="http://examplesite.com/resources/fullcalendar/gcal.js" ></script>
<script src="http://examplesite.com/resources/js/custom.js"></script> <!-- Contains script above -->
</head>
<body>
   <div id="teenCal"></div>
</body>

</html>

我试过lazyFetching = false,在renderView()上重新获取事件,似乎没什么用。

编辑:将日历更改为11月和12月有事件的日历。这是我在renderView()上使用refetching的方法 - 我不知道它是否正确完成。

$(document).ready(function() {

    $("#teenCal").fullCalendar({
        aspectRatio: 1.5,
        googleCalendarApiKey: 'AIzaSyCnfBoDwvGDCIfltN7P_ys-5MW5GGIYq8Q',
        events: { googleCalendarId: 'gchrl.org_2jguin31a4ac76bpbri5dq6jb4@group.calendar.google.com',
        backgroundColor: 'purple',
        borderColor: 'purple' },
        header: { left: 'prev', center: 'title', right: 'next' },
        viewRender: function(view, element) {
            element.fullCalendar('refetchEvents');
            }
    });
});

现在,在我看来,基于应该有效的文档。但我可能误解了viewRender调用中的“元素”,或者没有正确实现它。

0 个答案:

没有答案
相关问题