简体   繁体   中英

Refresh Calendar Data Div Without Refreshing Page

Any info on how i can refresh a div which contains a FullCalendar Calendar?

I want to just refresh the div to check for new data from the database which it pulls from without editing the ViewModel or refreshing the page. Every 30 Seconds.

index.html

<div id='calendar' style="background-color: #fff;"></div>

@section scripts{
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var calendarEl = document.getElementById('calendar');

            let calendar = new FullCalendar.Calendar(calendarEl, {
                plugins: ['resourceTimeGrid'],
                defaultView: 'resourceTimeGridDay',
                schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
                businessHours: true,
                nowIndicator: true,
                minTime: "07:00:00",
                maxTime: "19:00:00",
                header: false,
                height: "parent",
                eventTextColor: '#fff',
                eventColor: '#005d99',
                resources: @Html.Raw(Json.Serialize(Model.Resources)),
                events:  @Html.Raw(Json.Serialize(Model.Events))
            });

            calendar.render();
        });
    </script>
}

Simply you can assign array list to calendar source as below:

EventArray = jQuery.parseJSON(response.Data);
$('#calendar').fullCalendar('addEventSource', EventArray);
$('#calendar').fullCalendar('destroy');
loadcalendar();// Calendar init

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