Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load resources on-demand and sync it with events? #376

Open
coirpower opened this issue Nov 8, 2024 · 1 comment
Open

How to load resources on-demand and sync it with events? #376

coirpower opened this issue Nov 8, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@coirpower
Copy link

`<script>
document.addEventListener('DOMContentLoaded', function() {

    // Embed resources directly using PHP variable
    var resources = @json($staffs);

    var calendarEl = document.getElementById('calendar');

    var calendar = new EventCalendar(calendarEl, {
        view: 'resourceTimelineWeek',
        firstDay: 1,
        slotDuration: {days: 1},
        headerToolbar: {
            start: 'prev,next today',
            center: 'title',
            end: 'resourceTimelineWeek'
        },
        eventSources: [
            {
                url: '/attendance/resourcesAndAttendance',
                method: 'GET',
                failure: function() {
                    alert('There was an error while fetching events!');
                }
            }
        ],
        views: {
            resourceTimelineWeek: {
                pointer: true, 
                resources: resources
            }
        },
        dayMaxEvents: true,
        nowIndicator: true,
        selectable: false            
    });
});

</script>`

I use the above code but it looks like the calendar loads resources at initialization and does not automatically refresh them when I fetch events.

Basically, I have server side code that will return only the required resources and their events, and would like the calendar to fetch and load these dataset at runtime. Any suggestions?

@vkurko vkurko added the dependencies Pull requests that update a dependency file label Nov 11, 2024
@vkurko
Copy link
Owner

vkurko commented Nov 11, 2024

It seems that something like refetchResources() is needed. I will try to implement it in future versions.

@vkurko vkurko added enhancement New feature or request and removed dependencies Pull requests that update a dependency file labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants