0
How do I make the user by dragging an event to another date at the same time, return it to the previous date? It already sends an alert if the event is at the same time, but it only returns to the previous date when I press F5. See below the structure:
<script src="fullcalendar/moment.min.js"></script>
<script src="fullcalendar/fullcalendar.min.js"></script>
<script src='fullcalendar/locale/pt-br.js'></script>
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
validRange: {
start: '<?php echo date("Y-m-d"); ?>'
},
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: Date(),
navLinks: true,
editable: true,
eventLimit: true,
eventClick: function(event) {
$('#visualizar #id').text(event.id);
$('#visualizar #id').val(event.id);
$('#visualizar #title').text(event.title);
$('#visualizar #title').val(event.title);
$('#visualizar #start').text(event.start.format('DD/MM/YYYY HH:mm:ss'));
$('#visualizar #start').val(event.start.format('DD/MM/YYYY HH:mm:ss'));
$('#visualizar #color').val(event.color);
$('#visualizar #description').val(event.description);
$('#visualizar').modal('show');
return false;
},
selectable: true,
selectHelper: true,
select: function(start, end){
$('#cadastrar #start').val(moment(start).format('DD/MM/YYYY HH:mm:ss'));
$('#cadastrar #end').val(moment(end).format('DD/MM/YYYY HH:mm:ss'));
$('#cadastrar').modal('show');
},
events:<?php echo $metodos->visualizarAgenda($idEmpresa,$idUsuario); ?>,
eventDrop:function(event)
{
var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
var title = event.title;
var id = event.id;
$.ajax({
url:"alterar-dia-agenda.php",
type:"POST",
dataType: 'JSON',
data:{start:start,id:id},
success:function(sucesso){
if(sucesso.hasEvent == false){
$('#confirmar').modal('show');
temporiza();
calendar.fullCalendar('refetchEvents');
}else{
$('#erro').modal('show');
temporiza();
calendar.fullCalendar('refetchEvents');
}
}
});
}
});
});
</script>
Use the event updatEvent to update the date. If you are using
momentjs
, just use the methodsubtract
to change the date.– Valdeir Psr
Hello Valdeir. Sorry, I could not understand, because I know very little jquery and fullcalendar. In this case, the event would return to the previous date if the user drags to a date with an existing time?
– user24136
The update I’m able to do, the problem is that when I drag an event to a certain date with the same time, it manages to do this check, but does not return the previous date, only when I press F5.
– user24136
Post the drag event code, only with the Ajax it gets complicated because I don’t know if you’re using
momentjs
, which event you are manipulating, are know the values of the variablesstart
andid
etc..– Valdeir Psr
Right. I posted the full code.
– user24136
Following example: https://jsfiddle.net/valdeirpsr/gnhevdt4/4/ Ps.: Will not work on the site
jsfiddle
– Valdeir Psr
Right Valdeir. I will access the link and adapt in my code.
– user24136