全日历标题范围在新版本的周视图中是错误的

fullcalendar title range is wrong in new version for the week view

我正在为我的项目使用最新版本的完整日历。 3.1.0 我注意到我在这里尝试完成的工作实际上曾经有效,但后来在某种形式的版本 2.. 中被破坏了。 请查看这些小提琴进行比较。

旧版本:

Fiddle that works

新版本:

Fiddle that doesn't work

上面的两个小提琴都使用这种类型的代码来设置标题:

$('#calendar').fullCalendar({
    defaultView: 'basicWeek',
    header: {
        left: 'prev,next today',
        center: 'title',
        right: ''
    },       
    editable: true,
    weekends:false,

请注意,在工作中,标题会根据日期正确调整,其中 none 工作中仍然列出星期六和星期日范围 你能告诉我有什么变化以及为什么它被破坏了吗? 我认为他们正在修复,但我现在可以做些什么来修复代码吗?

试试这个:

$('#calendar').fullCalendar({
  defaultDate: moment(),
  header: {
    left: 'prev,next today',
    center: 'title',
    right: ''
  },
  defaultView: 'basicWeek',
  weekends: false,
  eventAfterAllRender: function(view) {
    var firstDate = moment($('th.fc-day-header:first').data("date"));
    var lastDate = moment($('th.fc-day-header:last').data("date"));
    if (firstDate.month() == lastDate.month()) {
      $('.fc-center').find('h2').html(firstDate.format('MMM') + ' ' + firstDate.format('D') + ' - ' + lastDate.format('D') + ', ' + firstDate.format('YYYY'));
    } else {
    //logic to show title for dates with different months / years
      $('.fc-center').find('h2').html('');
    }
  }
});

Fiddle