使用我的代码,我一直在使用jquery fullcalender而没有问题。直到十二月到来。对于事件函数calMonth = 0和calYear = 2018.我可以导航回到11月,一切都很好。我确实有12月的活动......我做错了什么?我知道0 = 1月。
ID 1 2 3 4 5
101 N P N P R
102 P P R R R
103 N N P P
104 P P R
105 N N
});
控制器操作
$(document).ready(function() {
var d = new Date();
var $month = (d.getMonth() + 1);
var $year = d.getFullYear();
$("#month").val($month);
$("#year").val($year);
var $timezone = "Central Time Zone";
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
events: function (start, end, $timezone, callback) {
var calMonth = end._d.getMonth();
var calYear = end._d.getFullYear();
$("#month").val(calMonth);
$("#year").val(calYear);
var edata = JSON.stringify({ month: $("#month").val(), year: $("#year").val() });
$.ajax({
type: "POST",
url: "/Events/GetCalendarData",
contentType: "application/json; charset=utf-8",
data: edata,
dataType: "json",
success: function (res) {
callback(res);
},
error: function (xhr, status, error) {
var errorData = xhr.responseText;
}
});
},
eventClick: function(event, jsEvent, view) {
$('#modalTitle').html(event.title);
$('#modalBody').html(decodeURIComponent(event.description));
$('#fullCalModal').modal();
if (event.url) {
return false;
}
}
});
模型
public ActionResult Index()
{
var model = new EventsModel();
return View(model);
}
public JsonResult GetCalendarData(int month, int year)
{
EventsModel model = new EventsModel();
return Json(model.GetSchoolEvents(month, year), JsonRequestBehavior.AllowGet);
}
答案 0 :(得分:0)
所以fullcalendar做日期的方式让我失望。这有效:
events: function (start, end, $timezone, callback) {
var startDate = new Date(start);
startDate.setDate(startDate.getDate() + 10);
var calMonth = startDate.getMonth() + 1;
var calYear = startDate.getFullYear();
$("#month").val(calMonth);
$("#year").val(calYear);