如何在fullcalendar(jquery插件)中绑定年份和月份下拉列表?

Pus*_*ari 5 jquery-plugins fullcalendar

我的要求是将这两个下拉列表与 fullcalendar 绑定并反映相应的更改。我已经搜索了很多关于将自定义下拉列表绑定到完整日历的信息,但还没有成功!!

因此,任何帮助表示赞赏。

需要这些下拉与全日历绑定

cha*_*thy 5

$(document).ready(function() {
    var $months = $('#months');
    var $calendar = $('#calendar');

    $calendar.fullCalendar({
        viewRender: function() {
            buildMonthList();
        }
    });

    $('#months').on('change', function() {
        $calendar.fullCalendar('gotoDate', $(this).val());
    });

    buildMonthList();

    function buildMonthList() {
        $('#months').empty();
        var month = $calendar.fullCalendar('getDate');
        var initial = month.format('YYYY-MM');
        month.add(-6, 'month');
        for (var i = 0; i < 13; i++) {
            var opt = document.createElement('option');
            opt.value = month.format('YYYY-MM-01');
            opt.text = month.format('MMM YYYY');
            opt.selected = initial === month.format('YYYY-MM');
            $months.append(opt);
            month.add(1, 'month');
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

请检查此小提琴的月份和年份下拉列表以获取全日历。

https://jsfiddle.net/L6a5LL5b/