2016-05-08 67 views
-1

这是我的javascript代码,使用fullcalendar部分:eventDrop与ASP.NET MVC

<script type="text/javascript"> 
$(document).ready(function() { 

    $('.i-checks').iCheck({ 
     checkboxClass: 'icheckbox_square-green', 
     radioClass: 'iradio_square-green', 
    }); 

    $('#calendar').fullCalendar({ 
     header: { 
      left: 'prev,next today', 
      center: 'title', 
      right: 'month,agendaWeek,agendaDay' 
     }, 
     weekNumbers: true, 
     eventLimit: true, 
     editable: true,    
     events: '/Service/GetEventSources/', 
     eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) { 
      $.ajax({ 
       url: '/Service/ChangeEvent/', 
       dataType: 'POST', 
       data: { 
        id: event.id, 
        start: event.start, 
        end: event.end 
       }, 
      }); 
     }, 
    }); 
}); 
</script> 

这是C#的一部分,在这里我想做一个数据库更新我的ASP.NET MVC的Web 应用:

[HttpPost] 
public JsonResult ChangeEvent(int id, DateTime start, DateTime end) 
{ 

    return Json(new 
    { 
     id =id, 
     start = start.ToString("s"), 
     end = end.ToString("s") 
    }, JsonRequestBehavior.AllowGet); 
} 

我使用我的C#的Web这种捆绑配置应用程序:

// fullCalendar styles 
bundles.Add(new StyleBundle("~/plugins/fullCalendarStyles").Include(
"~/Content/plugins/fullcalendar/fullcalendar.css")); 

// fullCalendar 
bundles.Add(new ScriptBundle("~/plugins/fullCalendar").Include(
"~/Scripts/plugins/fullcalendar/moment.min.js", 
"~/Scripts/plugins/fullcalendar/fullcalendar.js", 
"~/Scripts/plugins/fullcalendar/lang/de.js")); 

我今天下载了这些文件(08.04.2016),以便它们是最新的。

POST功能“的ChangeEvent”中的“服务”控制器从未被称为 - 相反,我得到以下错误(从Chrome中调试模式): Google Debug View

有谁知道,这里有什么问题?

回答

0

我自己回答这个问题! 问题是JavaScript的一部分。事件 的开始和结束属性必须与format()一起使用。现在一切正常:

eventDrop: function (event, delta, revertFunc, jsEvent, ui, view) { 
     $.ajax({ 
      url: '/Service/ChangeEvent/', 
      dataType: 'POST', 
      data: { 
       id: event.id, 
       start: event.start.format(), 
       end: event.end.format() 
      }, 
     }); 
    },