我有一个成功运行的日历,但加载时间非常慢。每个事件都成功呈现,但用户在切换视图或浏览月/周/天时必须等待5-10秒。
我已经在下面展示了事件加载代码,我能做些什么来加快它的加载速度?
由于
<script type='text/javascript'>
$(document).ready(function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
//events: [{"title":"My Test Event","start":"Wed, 02 Nov 2011 13:00:00 EST","url":"http://edu","allDay":"false"}],
events: "JSONcalendarFeed.aspx",
defaultView: 'month',
weekends: false,
allDay: false,
minTime: 8,
maxTime: 19,
allDaySlot: false,
slotMinutes: 15,
weekMode: 'liquid',
defaultEventMinutes: 60,
firstHour: 8,
header: {
left: 'month,agendaWeek,agendaDay',
center: 'title',
right: 'prev,next today'
},
eventRender: function (event, element) {
var evtDesc = event.description;
var evtStart = event.start;
var evtEnd = event.end;
if (evtDesc || evtStart) {
element.qtip(
{
content: evtStart + ' - ' + evtEnd + '<br/>' + evtDesc,
position: {
corner: {
target: 'bottomMiddle',
tooltip: 'topMiddle'
}
},
style: {
name: 'light'
}
}
);
}
},
selectable: true,
selectHelper: true,
select: function (start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: false,
weekends: false
},
true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
},
editable: true
});
});
</script>
答案 0 :(得分:5)
总结评论:
请勿从Feed中发送所有事件,而只发送 start 和 end 之间发生的事件,这些事件是fullCalendar发送到Feed页面的参数。它们以秒中的unix时间戳发送。