Refresh div only when data is changed

0

I do not know if it's possible, but I'm working on FullCalendar. I have already been able to register and change the date using eventDrop , so far everything is right, but next to the calendar, I created an area where the last 05 events are registered. I wonder if it is possible to cause, by dragging an event to another date, automatically update the div where I bring the last 5 events from the database.

I know that using setInterval () this becomes possible, but my concern is that, as far as I know, setInterval () ends up requiring the server, so is it possible to activate the setInterval () of the div only when the date is changed?

    
asked by anonymous 04.06.2018 / 00:21

1 answer

1
var t;
function temporiza() {
    t = setTimeout(function () { 

        // Atualiza o DIV

        // Caso queira que o ciclo de temporização recomece, descomente abaixo.
        //temporiza();
    }, 1000 /* aguarda 1000 ms */);
}

....

$('#calendario').fullCalendar({
    ....
    , eventDrop: function (event, delta, revertCallback) {
            ....
        if (confirm('Deseja fazer esta mudança?')) {
            // Salva o evento.

            // Atualiza o DIV.
            if (!t) temporiza();
        } else {
            revertCallback(event);
        }
    }
});
    
04.06.2018 / 00:33