Full Calendar + Event + Event Drop + Ajax - Does not send date values
I am using jquery full calendar and I am trying to save an event when it gets dropped.
$('calendar').fullCalendar
({
theme: true,
defaultView: 'agendaWeek',
columnFormat:
{
week: "ddd"
},
header: false,
allDaySlot: false,
minTime: '6am',
maxTime: '9pm',
editable: true,
droppable: true,
drop: function (date, allDay)
{ // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEven开发者_开发知识库tObject.allDay = allDay;
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('calendar').fullCalendar('renderEvent', copiedEventObject, true);
},
eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view)
{
var a = event.start;
var b = event.end
$.ajax
({
url: MyURL,
type: 'Post',
data: { 'Start': a, 'End': b },
success: function (response)
{
}
});
}
)};
When I alert variable "a" & "b" it shows me that there is a time in these variables.
[HttpPost]
public void CreateSlot(string Start, string End)
{
}
I know that it is reaching this method but it never sends any of the parameters they are always null.
Any ideas why?
Edit
It seems to be something with the object or whatever. I tried it in the drop method to see if the same thing was happening and found the same things
however when I did this
drop: function (date, allDay)
{
$.ajax
({
url: MyURL,
type: 'Post',
data: { 'Start': date.getTime() },
success: function (response)
{
}
});
}
It had no problem. So I wonder if asp.net mvc can't find bind the date object. What I kind of find weird as I am using a string.
Convert date to C# supported format.
eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view)
{
var a= $('#calendar').fullCalendar('formatDate', event.start, "yyyy-MM-dd HH:mm:ss");
var b;
if (event.end != null||event.end != undefined) {
b = $('#calendar').fullCalendar('formatDate', event.end, "yyyy-MM-dd HH:mm:ss");
}
$.ajax
({
url: MyURL,
type: 'Post',
data: { 'Start': a, 'End': b },
success: function (response)
{
},
error: function (msg) {
revertFunc();
},
});
},
[HttpPost]
public void CreateSlot(DateTime Start, DateTime End)
{
}
Is it possible that since you are not listing json as the data type in your ajax call it's not being passed that way (and therefore your method doesn't get the parms correctly)?
i.e.,
$.ajax
({
url: MyURL,
type: 'Post',
data: { 'Start': a, 'End': b },
dataType: 'json',.....
精彩评论