0

是否可以在 fullcalendar-scheduler 中将视图的开始和结束日期传递给资源?eventSources 会自动提供这两个参数,但不会提供资源。我试过了

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!');
            }
        }
    ],

但这不起作用。

4

2 回答 2

1

V1.5.1 引入了一个解决方案:

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

从 v1.5.1 开始,如果 refetchResourcesOnNavigate 设置为 true,资源函数将接收开始、结束和时区参数

于 2017-04-05T11:21:16.967 回答
1

我使用了这个解决方案:

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);
        },

这将添加开始和结束参数,例如获取事件时。您可以添加 到 feed.php 并在 mysql select 中$feed_start = $_GET['start'];使用该变量。'$feed_start'我从https://github.com/fullcalendar/fullcalendar-scheduler/issues/246?_pjax=%23js-repo-pjax-container得到输入

于 2017-01-10T14:00:45.510 回答