Fullcalendar 从空月份移动时未出现的事件
如果我从一个有事件的月份移到一个没有事件的月份,然后再移回来,我的事件就不会再出现。在月与月之间进行活动很好。我必须刷新页面才能让他们回来。这是我的代码,我看不出有什么错误Fullcalendar 从空月份移动时未出现的事件,fullcalendar,Fullcalendar,如果我从一个有事件的月份移到一个没有事件的月份,然后再移回来,我的事件就不会再出现。在月与月之间进行活动很好。我必须刷新页面才能让他们回来。这是我的代码,我看不出有什么错误 $("#datepicker").fullCalendar({ header: { left: 'prev,next,cbRefresh', center: 'title', right: ''
$("#datepicker").fullCalendar({
header: {
left: 'prev,next,cbRefresh',
center: 'title',
right: ''
},
height: 750,
firstDay: 1,
weekNumbers: true,
editable: false,
eventLimit: true,
displayEventTime: false,
dayClick: function(seldate,jsEvent,view) {
window.location.href="multiple?dt="+seldate.format();
},
eventClick: function(evt,jsEvent,view) {
if(evt.id) {
window.location.href="details?id="+evt.id+"&dt="+evt.start.format();
}
},
events: {
url: servicePath+"calendar.php",
type: 'GET',
data: function() {
var theDate=$("#datepicker").fullCalendar('getDate');
return {
t: 'load',
uid: uid,
mon: theDate.month()+1
}
},
error: function(){
displayError("Events error: " +item.ErrorMessage);
}
},
eventRender: function(evt,ele,view) {
$(ele).each(function(){
$(this).attr("data-num",evt.start.format("YYYY-MM-DD"));
$(this).attr("data-worked",evt.worked);
$(".fc-title",this).attr("title",evt.activity);
});
},
eventAfterAllRender: function(view) {
if(view.name=="month") {
for(cDay=view.start.clone(); cDay.isBefore(view.end); cDay.add(1,'day')) {
var ttl=0;
var dateNum=cDay.format('YYYY-MM-DD');
$(".fc-event-container").find('.fc-event[data-num="'+dateNum+'"]').each(function(){
var currentWorked=$(this).attr("data-worked");
if(currentWorked) {
ttl+=parseInt(currentWorked);
}
});
//display the total and relevant buttons
if(ttl>0) {
var footer=$('.fc-day[data-date="'+dateNum+'"]').find(".fc-cell-footer");
$(footer).append('<a title="Delete all" class="btn btn-xs" href="delete?dt='+dateNum+'">'+
'<span class="glyphicon glyphicon-trash"></span></a>'+
'<a title="Copy" class="btn btn-xs" href="copy?dt='+dateNum+'">'+
'<span class="glyphicon glyphicon-copy"></span></a>'+
'<a title="List" class="btn btn-xs" href="list?dt='+dateNum+'">'+
'<span class="glyphicon glyphicon-th-list"></span></a>');
$(footer).append('<span class="ttlHours">Hours: '+buildTime(ttl)+'</span>');
}
}
}
},
dayRender: function(date,cell) {
var theDate=moment(date).format("YYYY-MM-DD");
$(cell).css("vertical-align", "bottom");
$(cell).append('<div class="fc-cell-footer"></div>');
},
customButtons: {
cbRefresh: {
text: 'Refresh',
click: function() {
$("#datepicker").fullCalendar("destroy");
buildCalendar();
}
}
}
});
听起来您提供的URL正在筛选日历应显示的事件。尝试一些简单的方法,例如:
$("#calendar").fullCalendar({
events: {
url: 'getcalendar.php',
type: 'POST',
data: {
},
success : function(response){
console.log("Updated events: "+response.length);
}
}
});
Php:
与实际的数据库工作无关,因为我知道这是触发并返回正确的数据,因为它每次都通过电子邮件向我发送SQL语句(在我测试它时)。当我启动日历时,日历上有7月份的事件并显示它们,然后我移动到没有事件的8月份。我回到7月份,什么都没有显示,但是sql是正确的
$("#calendar").fullCalendar({
events: {
url: 'getcalendar.php',
type: 'POST',
data: {
},
success : function(response){
console.log("Updated events: "+response.length);
}
}
});
<?php
$start = $_POST['start'];
$end = $_POST['end'];
$query = mysqli(X,"SELECT * FROM calendar startdate >= '$start' AND enddate <= '$end'");
echo json_encode(mysqli_fetch_array($query,MYSQLI_ASSOC));
?>