完整日历重新呈现事件



我正在使用与jQuery Mobile集成的Fullcalendar。当我尝试在事件期间使用以下方法动态添加新事件时pageshow它会导致 JavaScript 执行,如下所示

Uncaught TypeError: Cannot call method 'empty' of undefined

我的 JavaScript 代码

    $('#myCalendar').live('pageshow',function(event){
            Newevents = [
                    {
                        title  : 'event1',
                        start  : '2012-11-24 01:00',
                        color:'red'
                    },
                    {
                        title  : 'event2',
                        start  : '2012-11-25',
                        end    : '2012-11-27'
                    },
                    {
                        title  : 'event3',
                        start  : '2012-11-28 12:30:00',
                        allDay : false // will make the time show
                    },
                    {
                        title  : 'event4',
                        start  : '2012-11-29 01:30:00',
                        allDay : false // will make the time show
                    }
                ];
        $('#calendar').fullCalendar('renderEvent',Newevents);
        $('#calendar').fullCalendar('rerenderEvents'); 
    });
$('#myCalendar').live('pagecreate',function(event){

    $('#calendar').fullCalendar({
            // put your options and callbacks here
            header: {
                    left:   '',
                    center: '',
                    right:  ''
                    },
            firstDay :1,
            viewDisplay: function(view) {
                $('#calendarLabel').html(view.title);
            },
             events:[
                {
                    title  : 'event1',
                    start  : '2012-11-21 01:00',
                    end:'2012-11-24 02:00',
                    color:'red'
                },
                {
                    title  : 'event2',
                    start  : '2012-11-05',
                    end    : '2012-11-07'
                },
                {
                    title  : 'event3',
                    start  : '2012-11-09 12:30:00',
                    allDay : false // will make the time show
                },
                {
                    title  : 'event4',
                    start  : '2012-11-09 01:30:00',
                    allDay : false // will make the time show
                }
            ],
            eventClick: function(calEvent, jsEvent, view) {
                alert('Event: ' + calEvent.title);
            },
            dayClick: myDayClick,
            height: 999999999
           });

});

而不是

.fullcalendar( 'renderEvent', []);

.fullCalendar( 'rerenderEvents'); 

你试过吗?

.fullCalendar( 'addEventSource', NewEvents );

相关内容

  • 没有找到相关文章

最新更新