【发布时间】:2016-05-10 13:16:41
【问题描述】:
我使用了 FullCalendar ,创建了 1500 个事件。 每个事件都与特定的用户名相关。 我创建了一个自定义按钮,当用户按下它时 - 日历假设只向他显示与他相关的事件。 这种机制实际上是有效的,但我可能做错了什么,因为当事件很少(在 ~10 个事件上测试)时它工作正常,但现在我有 1500 个事件,它挂起我的浏览器并导致它卡住.. 任何帮助都会得到帮助。
代码:
$('#calendar').fullCalendar({
editable: false, // Disable editing events directly from GUIhed over 2 days - this is the time that the run is counted as few days run
customButtons: {
myReports: { //Filter my reports
text: 'My Reports',
click: function () {
events_to_remove = $('#calendar').fullCalendar('clientEvents', function(event) {
<?php echo "var sessionUsername = \"".$username."\";\n";?>
return event.username != sessionUsername;
});
$('#calendar').fullCalendar( 'removeEventSource',events_to_remove);
$.each( events_to_remove, function( key, e ) {
$('#calendar').fullCalendar( 'removeEvents',e.id);
});
}
},
allReports: { //Filter all reports
text: 'All Reports',
click: function() {
$('#calendar').fullCalendar( 'refetchEvents');
}
}
},
header: {
left: 'myReports allReports',
center: 'prev title next',
right: 'today agendaDay,agendaWeek,month',
},
//read DB
events: {
url: 'modules/scheduler/scheduler_backend.php',
type: 'POST',
data: {
type: 'fetch',
start: $('calendar').fullCalendar('getView').start,
end: $('calendar').fullCalendar('getView').end,
},
error: function() {
alert('there was an error while fetching events!');
},
success: function(response){
//console.log(response); //For debug
}
},
});
【问题讨论】:
标签: javascript php jquery fullcalendar