Update div only when data is changed

Asked

Viewed 27 times

0

I do not know if it is possible, but I am working on Fullcalendar. I have already managed to register and change the date using the eventDrop, So far all right, but next to the calendar, I created an area where shows the last 05 registered events. I wonder if it is possible to make, when dragging an event to another date, automatically update the div where I bring from the database the last 05 events.

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

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);
        }
    }
});
  • Perfect. Thank you very much Marcelo.

Browser other questions tagged

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