Reload Fullcalendar Events

1

By pressing the "btn_insert" button, once the data is saved, I need the events to be updated, and for that I am using .fullCalendar ('refetchEvents') that should reload the events, but it does not and I do not know why. I leave the code.

This is the fullcalendar code, which brings the events of the Database

$.post('<?php echo base_url();?>cCalendar/geteventos',
function(data){

 //alert(data); 

 $('#calendar').fullCalendar({

  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,agendaWeek,agendaDay,listMonth'
  },

  defaultDate: new Date(),
  navLinks: true, // can click day/week names to navigate views
  businessHours: true, // display business hours
  editable: true,
  events: $.parseJSON(data),

  dayClick: function(date, jsEvent, view) {

    date_last_clicked = $(this);
    $(this).css('background-color', '#bed7f3');
    $('#modal_registrar').modal();

   },


   minTime: "08:30:00",
   maxTime: "23:00:00"

});


});

The function to save the data

$("#btn_insert").click(function(){

 var rut_usu = $("#rut_usu").val();
 var rut_estu = $("#rut_estu").val();
 var id_mot = $("#id_mot").val();
 var fecha_ini = $("#fecha_ini").val();
 var fecha_ter = $("#fecha_ter").val();


 $.ajax({

  url: "<?php echo base_url(); ?>" + "cCalendar/insertar_cita/",
  type: 'post',
  data: { "rut_usu": rut_usu, "rut_estu": rut_estu, "id_mot" : id_mot , "fecha_ini": fecha_ini , "fecha_ter": fecha_ter},

  success: function(response){ 

       $("#modal_registrar").modal('hide');
       document.getElementById("form_ingresar").reset();
       $("#modal_confirmar").modal('show');
       $('#calendar').fullCalendar("refetchEvents");

       //console.log(response);
   }

  });
    
asked by Kvothe_0077 27.09.2017 в 17:21
source

1 answer

1

I do not know if the component you are using is this link The existence of that function did not know, but also in my particular case that refreshed completely did not help much because I needed to update the events but stay in the same place. That I achieved with these lines below

var actual = $('#calendar-place').fullCalendar('getDate');
$('#calendar-place').fullCalendar('gotoDate', new Date(((m === 0) ? y - 1 : y) + '-' + m + '-' + d));
$('#calendar-place').fullCalendar('gotoDate', actual);

In which what I do is to go back to the original position on the calendar date, so they were recharged where it was originally.

    
answered by 27.09.2017 в 17:53