【问题标题】:fullcalendar V4 dayClick not firingfullcalendar V4 day点击不触发
【发布时间】:2019-04-29 17:32:39
【问题描述】:

我正在尝试将基于 Fullcalendar 的旧 Web 应用程序转换为 V4。我无法让dayClick 开火。

我有这个 CodePen 示例:https://codepen.io/anon/pen/YMMEyN?&editable=true&editors=001

该示例是通过来自 FC 网站的 lik=nk 初始化的。见下文。默认情况下,它会显示dayGridMonth 视图。它包含interaction 插件,但dayClick 方法不会触发,无论我在哪一天点击单元格。

    document.addEventListener('DOMContentLoaded', function() {
      var calendarEl = document.getElementById('calendar');

      var calendar = new FullCalendar.Calendar(calendarEl, {
        plugins: [ 'interaction', 'dayGrid', 'timeGrid' ],
        defaultView: 'dayGridMonth',
        defaultDate: '2019-04-07',
        header: {
          left: 'prev,next today',
          center: 'title',
          right: 'dayGridMonth,timeGridWeek,timeGridDay'
        },
        dayClick: function(info) {
                    alert("dayClick ");
        },
        events: [
          {
            title: 'All Day Event',
            start: '2019-04-01'
          },
          {
            title: 'Long Event',
            start: '2019-04-07',
            end: '2019-04-10'
          },
          {
            groupId: '999',
            title: 'Repeating Event',
            start: '2019-04-09T16:00:00'
          },
          {
            groupId: '999',
            title: 'Repeating Event',
            start: '2019-04-16T16:00:00'
          },
          {
            title: 'Conference',
            start: '2019-04-11',
            end: '2019-04-13'
          },
          {
            title: 'Meeting',
            start: '2019-04-12T10:30:00',
            end: '2019-04-12T12:30:00'
          },
          {
            title: 'Lunch',
            start: '2019-04-12T12:00:00'
          },
          {
            title: 'Meeting',
            start: '2019-04-12T14:30:00'
          },
          {
            title: 'Birthday Party',
            start: '2019-04-13T07:00:00'
          },
          {
            title: 'Click for Google',
            url: 'http://google.com/',
            start: '2019-04-28'
          }
        ]
      });

      calendar.render();
    });

【问题讨论】:

  • 在 v4 和 v5 中,dayClick (fullcalendar.io/docs/v3/dayClick) 已被 dateClick (fullcalendar.io/ docs/dateClick)

标签: javascript fullcalendar fullcalendar-4


【解决方案1】:

我认为您的意思是 dateClick 而不是 dayClick

dateClick: function(info) {
    alert("dateClick");
},

供参考: dateClick() docs

【讨论】:

  • 您好,谢谢。你是对的,我在那里有错误的js。应该是alert(...)。我已经编辑了我的问题。
  • 嗨,没问题。让我知道dateClick 是否适合您,否则我可以尝试进一步帮助您。
  • 嗨,即使我进行了修改或将其更改为 console.log() dayClick 也不会触发。
  • 请再次阅读我的回答,问题在于您将函数命名为dayClick() 而不是正确的dateClick()console.log 无关紧要。
  • @7 Reeds 那是因为在 v4 中不再有 dayClick 这样的东西了。这是日期点击。更仔细地阅读答案。您也可以尝试查看文档:fullcalendar.io/docs/date-clicking-selecting
猜你喜欢
  • 1970-01-01
  • 2015-08-03
  • 1970-01-01
  • 2011-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-14
相关资源
最近更新 更多