jQuery FullCalendar JSON date issue

♀尐吖头ヾ 提交于 2019-12-06 14:46:27

问题


I am integrating jQuery plugin FullCalendar, overall it has been really straightforward. I however have ran into a problem with adding events to the calendar. I am using ASP.NET MVC 1.0 and have found and followed this post.

I am returning JSON to the FullCalendar and the events are getting bound, but they all show up as all day events. I am formatting the dates as ISO8601 format as documented at their site.

Calendar Javascript

$('#calendar').fullCalendar({
    events: "/Calendar/GetEvents/"
});

JsonResult

public JsonResult GetEvents(double start, double end)
{
    var fromDate = Utility.Dates.ConvertFromUnixTimestamp(start);
    var toDate = Utility.Dates.ConvertFromUnixTimestamp(end);

    List<GenericEventList> events = GETGENERICLISTOFEVENTS();
    return Json(events.ToArray()); 
}

JSON Result Value

[{"id":2,"title":"Test Event","start":"2010-03-14T11:00:00","end":"2010-03-14T16:00:00"},
{"id":3,"title":"Test Event1asasas","start":"2010-03-14T10:00:00","end":"2010-03-14T14:00:00"},
{"id":4,"title":"Test Event12","start":"2010-03-14T16:00:00","end":"2010-03-14T17:00:00"},
{"id":6,"title":"Test Event1aaa","start":"2010-03-14T10:00:00","end":"2010-03-14T14:00:00"}]

Any help is truly appreciated!


回答1:


make sure to set the allDay property to false for each event object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)




回答2:


Also, if your dates aren't padded with zeros, then the events won't show.
Ex. 2010-9-5 bad
Ex. 2010-09-05 good



来源:https://stackoverflow.com/questions/2445359/jquery-fullcalendar-json-date-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!