fullcalendar:包含开始和结束日期的资源

时间:2016-07-21 09:04:34

标签: fullcalendar-scheduler

是否可以在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!');
            }
        }
    ],

但这不起作用。

2 个答案:

答案 0 :(得分: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_start = $_GET['start'];来feed.php 并在mysql select中使用变量'$feed_start'。 我从https://github.com/fullcalendar/fullcalendar-scheduler/issues/246?_pjax=%23js-repo-pjax-container

获得了输入

答案 1 :(得分:0)

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

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

  

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

相关问题