Hey, Im new to Jquery and Ajax and Im trying to implement eventDrop callback with no success.
After event dragging and dropping, fullcalendar doesn’t save changes.
Here’s the code
<?= yii2fullcalendar\yii2fullcalendar::widget([
'events' => $events,
'id' => 'calendar',
'options' => [
'lang' => 'es',
],
'clientOptions' => [
'selectable' => false,
'editable' => true,
'droppable' => true,
'header' => [
'left' => 'prev,next,today',
'center' => 'title',
'right' => 'month,agendaWeek,agendaDay,listDay',
],
'minTime' => '08:00',
'maxTime' => '21:00',
'height' => 'auto',
'eventColor' => function($events){
foreach ($events as $ev){
$color = $ev->color;
}
return $color;
},
'eventClick' => new JsExpression($JsEventClick),
'eventDrop' => new JsExpression($JsEventDrop),
],
]);
?>
<?php
$JsEventDrop = 'function(event) {
$("#calendario-id").val(event.id);
$("#calendario-titulo").val(event.title);
$("#calendario-fecha_inicio").val(event.start);
$("#calendario-fecha_termino").val(event.end);
$("#calendario-color").val(event.color);
var event_data = {
id: $("#calendario-id").val(),
title: $("#calendario-titulo").val(),
descripcion: $("#calendario-descripcion").val(),
start: $("#calendario-fecha_inicio").val(),
end: $("#calendario-fecha_termino").val(),
color: $"#calendario-color").val(),
};
$.ajax({
type: "POST",
url: "index.php?r=calendario/update&id=" + event.id,
data: event_data,
});
}'
?>
Any help would be appreciated