0

Is it possible in fullcalendar-scheduler to pass start and end date of the view to the resources? eventSources are provided with these two parameters automatically, but resources not. I tried with

resources: {
        url: '<?= $resourcesRoute ?>,
        type: 'POST',
        data: {
            start: $('#calendarDaysoff').fullCalendar('getView').start,
        }
    },
    eventSources: [
        {
            url: '<?= $eventsRoute ?>',
            type: 'POST',
            data: {
                bla: 'bla'
            },
            error: function () {
                alert('There was an error while fetching events!');
            }
        }
    ],

but this does not works.

cwhisperer
  • 1,478
  • 1
  • 32
  • 63

2 Answers2

1

I used this solution:

resources: function(callback){
                        setTimeout(function(){
                        var view = $('#calendar').fullCalendar('getView');
                        $.ajax({
                url: 'feed.php',
                dataType: 'json',
                cache: false,
                data: {
                    start: view.start.format(),
                    end: view.end.format(),
                    timezone: view.options.timezone
                    }

                }).then(function(resources){callback(resources)});      
            },0);
        },

This will add start and end parameters like when fetching events. You can add $feed_start = $_GET['start']; to feed.php and use the variable '$feed_start' in mysql select. I got the input from https://github.com/fullcalendar/fullcalendar-scheduler/issues/246?_pjax=%23js-repo-pjax-container

Gusmar
  • 141
  • 1
  • 8
1

V1.5.1 introduces a solution:

https://fullcalendar.io/docs/resource_data/refetchResourcesOnNavigate/

Since v1.5.1, if refetchResourcesOnNavigate is set to true a resources function will receive start, end, and timezone parameters

user701152
  • 51
  • 2