我已经实现了fullcalendar
,可以从ajax调用中获取事件并正常工作。问题是我需要在每天的每个事件前面都有一个计数器,或者在每天的数字旁边的每一天的事件总数。例如,我希望每天在我的活动fullcalendar表上显示:
(3) 23 Oct
1# 10am Event1
2# 11am Event2
3# 12:30am Event3
第二天就像
(2) 24 Oct
1# 12am Event1a
2# 13pm Event2b
我尝试使用eventRender,但是当事件在表格的不同行上呈现时,我无法找到正确迭代它们的方法。
到目前为止的代码:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: false,
lang: 'el',
draggable: false,
events: {
url: '<?= base_url(); ?>appointments/ajaxgetall',
type: 'POST',
error: function() {
alert('there was an error while fetching appointments!');
},
color: '#D7B4A3',
textColor: 'white'
},
eventRender: function(event, element) {
element.find(".fc-time").each(function(index) {
element.find('.fc-time').prepend(index + " ");
});
},
eventClick: function(rantebou, jsEvent, view) {
if (rantebou.url) {
window.open(rantebou.url, '_self');
return false;
}
}
});
用于获取事件数组的php代码(ajaxgetall()):
$jsonArr = array(
'id' => $entry['id'],
'type' => $entry['app_type'],
'title' => $entry['name'].
" ".$entry['surname'].
". Office: ".$entry['app_office'].
". Title:".$entry['app_title'].
". Desc: ".$entry['app_description'],
'start' => $entry['app_date'],
'allDay' => false,
'office' => $entry['app_office'],
'description' => $entry['app_description'],
'className' => 'event_'.$entry['app_type'],
'url' => base_url().
'appointments/editappointment/'.$entry['id']
);