0
我试图用FullCalendar,它显示精细,与进料更新从数据库和谷歌日历事件。保存外(可弃)事件数据库
但我的问题是我怎么在页面当被按下时,可以让我在日历中传回的所有事件回我的控制器,所以我可以将它们保存到数据库上的单个保存按钮?
一些代码(视图):
$(document).ready(function() {
/* initialize the external events
-----------------------------------------------------------------*/
$('#external-events div.external-event').each(function() {
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
// it doesn't need to have a start or end
var eventObject = {
title: $.trim($(this).text()) // use the element's text as the event title
};
// store the Event Object in the DOM element so we can get to it later
$(this).data('eventObject', eventObject);
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
// -------- Calendar set up ...
$('#calendar').fullCalendar({
eventSources:
[
{ // Uk holidays
url: 'http://www.google.com/calendar/feeds/uk__en%40holiday.calendar.google.com/public/basic',
color: 'blue',
textColor: 'white'
},
{ // booked availability
url: '/avalibility/GetAvail',
color: 'red'
}
],
//... more set up
});
控制器代码:
public JsonResult GetAvail(double start, double end)
{
var startDateTime = FromUnixTimestamp(start);
var endDateTime = FromUnixTimestamp(end);
var events = from e in db.PROJECT_CALENDAR
select e;
var AvilList = new List<object>();
foreach (var e in events)
{
AvilList.Add(
new
{
id = e.ID,
title = e.Title,
description = e.Title,
start = e.DateStart,
end = e.DateEnd
});
}
return Json(AvilList.ToArray(), JsonRequestBehavior.AllowGet);
}