我正在使用与jQuery Mobile集成的Fullcalendar。当我在pageshow
事件期间使用以下方法动态add new events时,会导致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
});
});
答案 0 :(得分:5)
而不是
.fullcalendar( 'renderEvent', []);
和
.fullCalendar( 'rerenderEvents');
你试过......?
.fullCalendar( 'addEventSource', NewEvents );