如何查看2周并将下一个按钮的增量设置为1周



我创建了一个2周的自定义视图。

timelineTwoWeeks: {
    buttonText: '2 Weeks',
    type: 'timelineWeek',
    duration: { weeks: 2 }
},

但是当我点击下一步按钮时,视图的开始日期移动了2周,这不是我想要的情况。那么我怎样才能让它移动一周而不是两周呢?

编辑:

图解说明,让事情更清楚

Fullcalendar似乎默认按视图中显示的持续时间前进。似乎没有办法通过配置/选项来覆盖它,所以一个解决方案可以是:

https://jsfiddle.net/a0j9v7gu/

$('#calendar').fullCalendar({
    views: {
        basicTwoWeeks: {
            buttonText: '2 Weeks',
            type: 'basic',
            duration: {
                weeks: 2
            }
        }
    },
    /* Fullcalendar doesn't appear to support advancing calendar with default prev,next buttons
        a different interval than the duration displayed by the view. So, we make our own buttons! */
    customButtons: {
        mynext: {
            text: 'Next',
            click: function() {
                var $cal = $('#calendar');
                /* change to a lesser duration view (week, day).
                    if you don't the 'next' button won't work as expected.
                    comment out following line and see
                */
                $cal.fullCalendar('changeView', 'basicWeek');
                $cal.fullCalendar('incrementDate', moment.duration(1, 'week'));
                /* pop back to two-week view */
                $cal.fullCalendar('changeView', 'basicTwoWeeks');
            },
        },
        myprev: {
            text: 'Prev',
            click: function() {
                $('#calendar').fullCalendar('incrementDate', moment.duration(-1, 'week'));
            }
        }
    },
    header: {
        left: '',
        center: 'title',
        right: 'myprev,mynext'
    },
    defaultView: 'basicTwoWeeks',
    defaultDate: '2016-10-01'
});

最新更新