fullCalendar 今天按钮自定义行为

fullCalendar today button custom behavior

我在使用 fullCalendar 时遇到了麻烦。我正在使用周视图(默认视图:'basicWeek')和工具栏按钮 'today'、'prev'、'next'。当我单击 'today' 按钮时,日历会导航回当前周,但日期 selection 不会更改。我希望日历导航到当前周和日历上的 select 今天日期。但是我在重新定义 'today' 按钮点击事件时遇到了麻烦。

代码示例:https://plnkr.co/edit/dv9yiq1CdJxfFTsDg4Yx?p=preview

defaultView: 'basicWeek',
            defaultDate: '2016-01-12',
            selectable: true,
            selectHelper: true,
            select: function(start, end) {
              console.log('select');
                var title = prompt('Event Title:');
                var eventData;
                if (title) {
                    eventData = {
                        title: title,
                        start: start,
                        end: end
                    };
                    $('#calendar').fullCalendar('renderEvent', eventData, true); 
                }
                $('#calendar').fullCalendar('unselect');
            }

当我点击case.So中的'today'按钮时,我想要一个今天日期的弹出窗口(提醒),基本上按钮点击不仅导航到本周,而且导航到select 当前日期。

您可以手动收听今天的按钮点击,然后调用日历的 select 方法传递正确的参数。

试试下面的代码: https://plnkr.co/edit/62Dx5pVrDDXnwoME5jbU?p=preview

calendar.find('.fc-today-button').click(function(){
  var start = new Date();
  start.setHours(0,0,0,0);
  var end = new Date();
  end.setDate(end.getDate() + 1);
  end.setHours(0,0,0,0);
  calendar.fullCalendar('select', start, end);
});