Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

667
Visualizações
FullCalender - How to automatically fetch and display previous events?

I am trying to display previous events in fullCalendar. But there's a problem: after you define an event and then refresh the page the events disappear.

Is there any way that I can fetch all the details from all the previous events and display them on the calendar?

This is my code:

document.addEventListener('DOMContentLoaded', function() {
    var calendarEl = document.getElementById('calendar');

    let calendar = new FullCalendar.Calendar(calendarEl, {
        timeZone: 'UTC',
        initialView: 'dayGridMonth',
        selectable: true,
        headerToolbar: {
            left: 'prev,next',
            center: 'title'
        },
        editable: true,
        eventClick: function(info) {
            info.jsEvent.preventDefault(); // don't let the browser navigate

            if (info.event.url) {
                window.open(info.event.url);
            }
        },
        dateClick: function(info) {
            endDate = info.dateStr;
            localStorage.enddate = info.dateStr;
            setTimeout(cal, 1000);

            function cal() {
                if (imgUrl !== ' ' && today <= endDate) {
                    calendar.addEvent({
                        title : `Post ${l++}`,
                        url   : `${imgUrl}`,
                        start : `${today}`,
                        end   : `${endDate}`
                    });

                    imgUrl = ' ';
                } else if (today > endDate) {
                    alert('Please select a date that is in the future!');
                } else {
                    return;
                }
            }

            var today = new Date();
            var dd = String(today.getDate()).padStart(2, '0');
            var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
            var yyyy = today.getFullYear();
            today = yyyy + '-' + mm + '-' + dd;

            const date1 = new Date(`${today}`);
            const date2 = new Date(`${endDate}`);
            seconds = date2 - date1;
            console.log(seconds);
        }
    });

    calendar.render();
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda