Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

665
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!