Cannot get FullCalendar to populate with my event array

时间:2018-01-23 19:14:43

标签: asp.net json asp.net-mvc fullcalendar

I have researched and I cannot get my solution to work. I have created my rest service to provide the event data as needed...

[
  {"id":"cb2eb05b-7a24-431c-8948-d08fb51f6bab","title":"Happy Birthday Pat!","allDay":false,"start":"2017-12-30T03:00:00","end":"2017-12-31T02:30:00","url":""},
  {"id":"89fdeab5-1f49-4416-b81c-d9d9a3c4fbde","title":"RailJam on Westway","allDay":false,"start":"2017-12-31T15:00:00","end":"2017-12-31T19:00:00","url":""},
  {"id":"37afb0e6-e659-46a3-a048-5f13560ebe87","title":"Senior OEC Clinic","allDay":false,"start":"2018-01-07T11:00:00","end":"2018-01-07T19:00:00","url":""},
  {"id":"6d74033c-39ce-4d43-b642-bceed34e2294","title":"Senior OEC Clinic","allDay":false,"start":"2018-01-21T11:00:00","end":"2018-01-21T19:00:00","url":""},
  {"id":"36ca8f3b-6696-49f4-b7b7-a405660358e8","title":"Senior OEC Clinic","allDay":false,"start":"2018-01-28T11:00:00","end":"2018-01-28T19:00:00","url":""},
  {"id":"3b1a86ec-d09a-467d-ad83-43864439db1f","title":"Senior OEC Clinic","allDay":false,"start":"2018-02-03T11:00:00","end":"2018-02-03T19:00:00","url":""}
]

I have create my MVC page with the fullcalendar plug in...

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<link href="../../FullCalendar/fullcalendar.css" rel="stylesheet" type="text/css" />
<script src="../../FullCalendar/lib/moment.min.js" type="text/javascript"></script>
<script src="../../FullCalendar/lib/jquery.min.js" type="text/javascript"></script>
<script src="../../FullCalendar/fullcalendar.min.js" type="text/javascript"></script>

<script>
    $(document).ready(function () {
        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,basicWeek,basicDay'
            },
            color: 'blue',
            textColor: 'white',
            events: 'http://localhost:3276/rest/bsp/events/'
        });
    });
</script>

<div id='calendar'></div>

But I am still not able to get my events to publish on the calendar.

Missing Events In FullCalendar

I am sure it is a simple mistake that I have missed...can anyone shed some light?

1 个答案:

答案 0 :(得分:0)

成功。我的结果用HTML包装,所以不是纯粹的JSON。通过返回流返回的纯JSON字符串进行更正,而不是字符串的HTML表示。