FullCalendar"无法阅读财产' getDay'未定义"

时间:2014-05-19 17:09:10

标签: javascript rendering fullcalendar

我使用下面的脚本加载我的日历活动。奇怪的是,有时似乎汤姆负载很好,有时它根本不想加载。如果它有任何区别,则会以jquery模式加载。

$(document).ready(function() {
    /* $('.calMessagesBG').click(function(){
        $('.calMessagesContainer').fadeOut(750);
        $('.calMessagesBG').fadeOut(1250);
    }); */
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    <?php //Extend the date object (not part of fullcalendar) ?>
    Date.prototype.addDays = function(days) {
        this.setDate(this.getDate() + days);
        return this;
    };<?php //end of extension ?>
    var earliestDate = new Date(); <?php // the earliest date that a package can be created ?>
    earliestDate.addDays(0);
    <?php //earliestDate.setHours(23,59,59);  //This sets the time to 11:59:59 PM - this is our way of expressing the end of the earliest day to creat booking ?> 

    var calendar = $('#calendar').fullCalendar({
        height:400,
    //configure options for the calendar
       header: {
          left: 'prev,next today',
          center: 'title',
          right: 'month,agendaWeek,agendaDay'
       },
       // this is where you specify where to pull the events from.
       events: "/events/byID/25", 
       editable: false,
       defaultView: 'month',
       allDayDefault: false,
        loading: function(bool) {
            if (bool){
                $('.calMessages').html('<p style="width:300px">Collecting packages & booking info...</p>');
                $('.calMessagesBG').fadeIn(750);
                $('.calMessagesContainer').fadeIn(1250);
            } else {
                $('.calMessagesContainer').fadeOut(150);
                $('.calMessagesBG').fadeOut(500);
            }
        }, 
        allDaySlot: false, 
   });

});

我收到以下错误:

 XHR finished loading: GET "http://itrekkers.com/events/byID/25?start=NaN&end=NaN&_=1400518976875". jquery-1.10.2.js:6
 Uncaught TypeError: Cannot read property 'getDay' of undefined 

结果数据样本:

 [{"id":"$2y$10$.UNkHkjRq91fd5ibB9x23.9G9ZB3lcz5B1RGb\/tbSQt85BYxYjOt6","title":"Two hour ocean experience","color":"#2798CF","textColor":"#ffffff","start":"2014-05-04 20:00:00","end":"2014-05-04 22:00:00"}]

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,因为fullCalendar对象还没有准备就绪。只有在完全构建完成后才尝试使用fullCalendar方法。