I cannot get the FullCalendar jquery plugin to bind to a Json array coming from an ASP.NET MVC3 action.
I removed almost everything from the code to try to track down the problem; I stayed with this, which of every SO and blog post I read should work:
Action (calendar controller)
public JsonResult Events(double start, double end) { var rows = new object[] { new { title="Event1", start= "2011-04-04" }, new { title="Event2", start= "2011-04-05" } }; return Json(rows, JsonRequestBehavior.AllowGet); }
View
<script type='text/javascript'> $(document).ready(function () { $('#calendar').fullCalendar({ events: '@Url.Content("~/Calendar/Events")' }) });
The results are an empty calendar with no related events. I checked that Json is being retrieved:
Json result
[{"title":"Event1","start":"2011-04-04"},{"title":"Event2","start":"2011-04-05"}]
And it works great:
$(document).ready(function () { $('#calendar').fullCalendar({ events: [{title: 'Event1',start: '2011-04-04'}, {title: 'Event2',start: '2011-04-05'} ]}); });
I tried using all the number of date formats (including ISO8601 and * nix timestamps and got the same result: no related events, just an empty calendar. If I add the $ .ajax error: function function to the .fullCalendar object, it fires, so maybe something with John's return, but it looks good to me.
I am using FullCalendar 1.5 (although I also tried 1.4.11), JQuery 1.5.1, JQueryUI 1.8.11.
I have tried everything that I can think of - any ideas are greatly appreciated!