Event back to the previous date when there is an event already registered at the same time

Asked

Viewed 161 times

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>

inserir a descrição da imagem aqui

  • Use the event updatEvent to update the date. If you are using momentjs, just use the method subtract to change the date.

  • 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?

  • 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.

  • 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 variables start and id etc..

  • Right. I posted the full code.

  • 1

    Following example: https://jsfiddle.net/valdeirpsr/gnhevdt4/4/ Ps.: Will not work on the site jsfiddle

  • Right Valdeir. I will access the link and adapt in my code.

Show 2 more comments

1 answer

-1

Good morning my comrade, this function of issuing a meeting change alert at the same time as it was held ? I could not find anything yet.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.