Populate saved events in database on fullcalender in jQuery?
I am able开发者_开发知识库 to save the events of particular date wise in database by using fullcalender jQuery. But how to populate the saved events in database on fullcalender jQuery control, of the corresponding date?
Without knowing what language you are using on the server it makes it a bit hard to give you an answer...
I have used FullCalendar in a few .NET MVC solutions with great success... I return back JSON in the following format (snipped from my existing code):
[{
id = a.AppointmentID,
start = a.Appointment.DateTime,
title = a.Appointment.Total,
allDay = a.Appointment.AllDay,
leave = a.Appointment.Leave,
end = a.Appointment.DateTime.AddHours((double)a.Appointment.Duration),
url = "/Appointments/Edit/" + a.AppointmentID,
}]
On the client side, I use the following to request the JSON from my MVC Action:
function getEvents(start, end, callback) {
var calendar = $(this);
var id = calendar.attr('staffid');
$.ajax({
url: '/Appointments/Events',
dataType: 'json',
data: {
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000),
staffID: id,
_d: new Date().getTime()
},
success: function (json) {
callback(json);
}
});
}
More information on the Event structure is available in the FullCalendar help at http://arshaw.com/fullcalendar/docs/event_data/Event_Object/ and http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/
Hope this helps.
精彩评论