我想传入一组ID,用于选择我想要显示的事件。如果我不将“data”属性与ID数组一起使用,则fullcalendar会显示所有事件。添加数据属性后,我收到错误消息“获取事件时出错!”
这是文档就绪功能:
factory
这是C#方法:
var groupSelectedArray = [];
groupSelectedArray[0] = '1';
groupSelectedArray[1] = '2';
$('#calendar').fullCalendar({
header:
{
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
titleFormat: {month: 'MMMM'},
defaultView: 'month',
editable: false,
events: function (start, end, groupSelectedArray, callback) {
$.ajax({
type: "POST",
url: '@Url.Action("GetAllEvents", "Home")',
data: { selectedGroups: groupSelectedArray },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (doc) {
var events = [];
$(doc).each(function () {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
id: $(this).attr('id'),
description: $(this).attr('description'),
color: $(this).attr('color'),
textColor: 'black'
});
});
callback(events);
} ,
error: function () {
alert("There was an error fetching events!")
}
});
}
谁能看到我哪里出错了? 感谢。
答案 0 :(得分:0)
我为实现这一目标所做的是改变了数据' ajax调用的一部分: 替换这个:
{ selectedGroups: groupSelectedArray },
到此:
data: JSON.stringify(groupData),