I'm using the select callback when adding events. The following code worked in v1 but I'm getting the Uncaught TypeError in v2. When I remove the ajax code there is no error but of course I need to add the new event to the database.
select: function(start, end, jsEvent, view) {
var title = 'Available';
var eventData;
eventData = {
title: title,
start: start
};
$.ajax({
type : 'POST',
url : 'add-event.php',
data: eventData,
success : function(data){
$('#calendar').fullCalendar('renderEvent', {
id: data.id,
title: data.title,
start: data.start,
start: data.end
}, true);
$('#calendar').fullCalendar('unselect');
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
}
});
},
Try send startDate and endDate in a format use format()
for it.
select: function(start, end, jsEvent, view) {
var title = 'Available';
var eventData;
eventData = {
title: title,
start: start
};
$.ajax({
type : 'POST',
url : 'add-event.php',
data: eventData,
success : function(data){
$('#calendar').fullCalendar('renderEvent', {
id: data.id,
title: data.title,
start: data.start.format(),
end: data.end.format()
}, true);
$('#calendar').fullCalendar('unselect');
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
}
});
},
You can refer to Momentjs
Please check the event data . Source attribute of your event must be null or not populated. SO before calling
$('#calendar').fullCalendar('renderEvent', event);
You have to be make sure that required attribute of your fullcalendar event must be populated. Here is the link for required and optional fieldfor event object.
http://fullcalendar.io/docs/event_data/Event_Object/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With