开发者

unable to set dynamic data in jquery fullcalendar through ajax

can somebody tell me how to populate "jquery fullcalendar" events using ajax.

There is no setter method provided in fullcalendar to set ajax response (which is Json object) after calendar object loads. Is there any way to feed data after calendar object loads?

In my case very first time I provide data in fullcalendar "event开发者_Python百科:" property and it is working fine. But when I press next or previous to switch one month to another, I'm unable to feed data into that.

Thnx in advance


in ASP.NET MVC View:

$('#calendar').fullCalendar({
  theme: true,
  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay'
  },
  events: "/Calendar/GetEvents/"
});

Contoller:

public JsonResult GetEvents() {
 List < DAL.VwMeeting > allMeeting = meetingRepository.GetAll();
 var eventList = from e in allMeeting
 select new {
  url = (e.MeetingOccurID).ToString(),
   title = e.MeetingTitle,
   start = ConvertToUnixTimestamp((DateTime) e.MeetingOccurStartDate),
   end = ConvertToUnixTimestamp((DateTime) e.MeetingOccurEndTime),
   allDay = false
 };
 return Json(eventList.ToArray());
}

or you can use:

$('#calendar').fullCalendar('refetchEvents');

after each event handle


Rather than fetching the events by Ajax and then putting them in the calendar, you can use the fullcalendar to do all of the Ajax for you:

$('#calendar').fullCalendar({
    events: "/myfeed.php"
});

Then the correct events will be fetched according to the range of dates the user is viewing. See the fullcalendar documentation for more info.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜