Currently, I am utilizing fullcalendar v4 (accessible at https://fullcalendar.io/) and facing an issue where I need to refresh the dropped event in a custom view called 'timeGridSixMonth'.
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'bootstrap', 'interaction', 'dayGrid', 'timeGrid', 'list' ],
defaultView: 'timeGridSixMonth',
header: {
left: 'prev,next today',
center: 'title',
right: 'timeGridSixMonth,timeGridWeek,timeGridDay,listSixMonth'
},
buttonText: {
timeGridSixMonth: '6 Month',
listSixMonth: 'List 6 Month'
},
views: {
timeGridSixMonth: {
type: 'dayGrid',
duration: { month: 6 },
titleFormat: { year: 'numeric', month: 'short', day: 'numeric' },
},
listSixMonth: {
type: 'listMonth',
duration: { month: 6 },
titleFormat: { year: 'numeric', month: 'short', day: 'numeric' }
}
},
.....
drop: function(info) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
console.log(info);
$.ajax({
url: '/api/plan',
type: "POST",
data: {
'title': info.jsEvent.explicitOriginalTarget.textContent
'item_id': $('#item_id').children("option:selected"). val(),
'start': start,
'end': end,
'users_id':{{ \Illuminate\Support\Facades\Auth ::user() -> id }},
},
success: function (response) {
console.log(response);
calendar.addEvent({
title: response.data.title,
start: response.data.start,
end: response.data.end,
allDay: false,
id: response.data.id,
});
displayMessage('gespeichert.');
}
});
},
The response is:
{
"success": true,
"data": {
"Fach": "Rhetorik",
"faecher_id": 22,
"dozenten_id": 112,
"schulungsorte_id": 18,
"Beginn": "2020-10-29T16:00:00.000000Z",
"Ende": "2020-10-29T20:00:00.000000Z",
"kurstermine_id": "14,17,7,21",
"users_id": 3,
"updated_at": "2020-04-01T16:15:34.000000Z",
"created_at": "2020-04-01T16:15:34.000000Z",
"id": 26,
"title": "Rhetorik\n Mr. Miller",
"start": "2020-10-29T16:00:00.000000Z",
"end": "2020-10-29T20:00:00.000000Z"
},
"message": "stored."
}
In the custom view, an event is being created without an ID causing addEvent() to fail.
Furthermore, when using standard views, duplicate events are being generated without IDs.
Any idea why this inconsistency is happening?