我在用事件填充 jQuery FullCalendar 时遇到了很多麻烦。
浏览器:IE8
技术:MVC 3 剃刀
正在使用的脚本:jquery-1.5.1、fullcalendar.js
控制器和支持方法:(即使我的问题是它一开始就没有出现)
     public JsonResult GetCalendarData()
    {
        List<CourseSection> courseSecs = //genarates list of course sections from db context
        var listOfEvents = new List<object>();
        foreach (CourseSection courseSec in courseSecs)
        {
            Course course = db.Course.Find(courseSec.CourseID);
            listOfEvents.Add(
            new
            {
                id = courseSec.ID,
                title = course.Name + "Section " + courseSec.Name,
                start = ToUnixTimespan(courseSec.sectionBeginDateAndDailyStartTime),
                end = ToUnixTimespan(courseSec.sectionEndDateAndDailyEndTime),
                allDay = false //none of the course sections run all day
            });
        }
        return Json(listOfEvents.ToArray(), JsonRequestBehavior.AllowGet);
    }
    private string ToUnixTimespan(DateTime date) //supporting method
    {
        TimeSpan tspan = date.ToUniversalTime().Subtract(
        new DateTime(1970, 1, 1, 0, 0, 0));
        return Math.Truncate(tspan.TotalSeconds).ToString();
    }
看法:
    @model Web.Models.Registration
     @{
     ViewBag.Title = "ViewSchedule";
     Layout = "~/Views/Shared/_SiteLayout.cshtml";
     }
     <script>
     $(document).ready(function () {
     // page is now ready, initialize the calendar...
     $('#calendar').fullCalendar({
              defaultView: "agendaWeek",
              year: 2013,
              month: 0,
              date: 25,
              minTime: 6,
              maxTime: 18,
              aspectRatio: 1.5,
              allDaySlot: false,
              events: "/Course/GetCalandarData"
              });
     });
     </script>
     <div class="wrapper col3">
       <div id="container">
         <h1>View Schedule</h1>
           <div id = 'calendar'>
           </div>
        <br />
        @Html.ActionLink("Home", "Home", "Static")
        <br />
       </div>
     </div>
问题:日历本身和所有配置都可以正常加载。但是,配置的最后一行(事件:“/Course/GetCalendarData”)不会触发。时期。它永远不会触发我放置在控制器方法中的任何调试块,并且不会返回任何 JSON。
我尝试在访问 URL 中添加强制性的“@Url.Content...”前缀。我曾尝试将该方法容纳在不同的控制器中。我尝试过使用不同版本的 jQuery。我已经删除了所有可能导致冲突的无关脚本。一切为了纳达。
我一直在为此扯头发。有任何想法吗?