我需要重新獲取不僅在日曆按鈕,但是對我自己的下拉改變全日曆事件,因爲它們定義爲事件搜索的條件。我至今使用$.ajax
,但現在的事件沒有得到日曆通過下拉菜單的值的唯一方法。我錯過了一些東西,因爲我完全不明白這個功能。Fullcalendar重取事件
$(function() {
InitializeCalendar();
$("#ProjectId").change(function() {
$('#calendar').fullCalendar('refetchEvents');
});
$("#JobId").change(function() {
$('#calendar').fullCalendar('refetchEvents');
});
$("#StoreId").change(function() {
$('#calendar').fullCalendar('refetchEvents');
});
$("#OrderType").change(function() {
$('#calendar').fullCalendar('refetchEvents');
});
$("#ShippingId").change(function() {
$('#calendar').fullCalendar('refetchEvents');
});
});
function InitializeCalendar() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: function (start, end) {
$.ajax({
url: '/Calendar/GetEvents/',
dataType: 'json',
data: {
start: Math.round(start.getTime()/1000),
end: Math.round(end.getTime()/1000),
projectId: $("#ProjectId option:selected").val(),
storeId: $("#StoreId option:selected").val(),
jobId: $("#JobId option:selected").val(),
orderType: $("#OrderType option:selected").val(),
shippingId: $("#ShippingId option:selected").val()
}
**SOMETHING MISSING HERE**
//this puts calendar into infinite loop
//$('#calendar').fullCalendar('refetchEvents');
});
}
});
}
控制器:
public JsonResult GetEvents(double start, double end, int? projectId, int? storeId, string orderType, int? shippingId, int? jobId)
{
// Some code...
IList<OrderEvent> events = orderDTOs.Select(orderDTO => new OrderEvent {
id = orderDTO.OrderId,
title = orderDTO.OrderId.ToString(),
start = ToUnixTimespan(orderDTO.CreatedDate),
end = ToUnixTimespan(orderDTO.CreatedDate.AddHours(1)),
url = "/Order/Search"
}).ToList();
return Json(events, JsonRequestBehavior.AllowGet);
}
我想知道這是如何解決的!謝謝 – Mathieu 2013-03-01 16:42:46
你解決了這個問題嗎?答案不起作用。 – Chookoos 2013-09-19 02:30:36