我有 fullcalendar 使用平面文件中的 json 可以很好地加载数据。
我想在单击上一个/下一个时从那个月的文件中加载每个月的数据。
使用 Ajax ?事件:函数(开始、结束、回调)addEventSource - removeEventSource?其他?
允许 jQuery 对我来说仍在进行中。
更新: 我已经设定: viewDisplay: function(view) { var next = view.title;警报(下一步); }, 单击下一个/上一个给我月年 如何将其解析为 json-events.php
我尝试了 [split next] 事件:“json-events.php?month=month”, 不……
最佳答案
这不是使用 php,但您可以更改 getCalData() 中的 AJAX 调用来执行此操作。 EventSource 将填充下一个数据。
希望对您有所帮助。
$(document).ready(function () {
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'resourceMonth'
},
defaultView: 'resourceWeek',
eventSources: [ getCalData() ],
header: {
left: 'prev,next today',
center: 'title',
right: ''
},
viewDisplay: function (view) {
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', getCalData());
$('#calendar').fullCalendar('rerenderEvents');
}
});
});
function getCalData() {
var source = [{}];
$.ajax({
async: false,
url: '/mysite/GetWeekData',
data: { myParam: $('#calendar').fullCalendar('getView').visStart },
success: function (data) {
$(data).each(function () {
source.push({
title: $(this).attr('title'),
start: $(this).attr('start'),
});
});
},
error: function () {
alert('could not get the data');
},
});
return source;
}
关于fullcalendar - 单击上一个/下一个并加载新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13263105/