简体   繁体   中英

setOption startParam works weird in fullcalendar v5

I was trying to set startParam option dynamically.

But it seems working weird by updating the key rather update value.

calendarEvents.setOption('startParam', moment().format());
calendarEvents.refetchEvents();

If I run the methods and check the form data, then the startParam will be look like the following.

2021-02-15T19:09:13-07:00: 2021-01-01T00:00:00-07:00
end: 2030-01-01T00:00:00-07:00

I guess the setOption method updates the key not value for the start params.

Why does this happen and how to fix this?

UPDATE: My calendar code

calendarEvents = new FullCalendar.Calendar(calendarEventsEl, {
        headerToolbar: false,
        contentHeight: 300,
        initialView: 'listAll',
        views: {
            listAll: {
                type: 'listYear',
                duration: { years: 9 },
            },
        },
        navLinks: false,
        eventDidMount: function (arg) {
            ...
        },
        eventTimeFormat: {
            hour: 'numeric',
            minute: '2-digit',
            meridiem: 'short'
        },
        eventSources: [{
            method: 'POST',
            url: '/calendar/get_all_by_id/' + id,
        }],
        eventSourceSuccess: function(content, xhr) {
            ...

            return events;
        }
    });

    calendarEvents.render();
})

It's working properly.

The startParam option sets the name of the parameter which fullCalendar sends to the server for the start value, when fetching events. It doesn't set the value. The value which is sent is always the start date of the range which the user has just navigated to. You don't need to change that value yourself, and anyway it makes no sense to try and give it a fixed value - it is adjusted dynamically by fullCalendar every time events need fetching.

What are you actually trying to achieve with this code? Are you trying to change the current date on the calendar programmatically? If so then use https://fullcalendar.io/docs/Calendar-gotoDate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM