簡體   English   中英

如何查看2周並將下一個按鈕的增量設置為1周

[英]How to view 2 weeks and set increment of next button to 1 week

我創建了一個為期2周的自定義視圖。

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

但是當我點擊下一個按鈕時,視圖的開始日期會進一步移動2周,這不是我想要的情況。 那么如何讓它移動1周而不是2周呢?

編輯: 圖形說明只是為了清楚

Fullcalendar顯示為默認prev,下一個按鈕按視圖中顯示的持續時間前進。 似乎沒有辦法通過配置/選項覆蓋它,因此解決方法可能是:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM