如何在Fullcalendar.js库中重写renderSlatRowHtml函数

时间:2018-10-23 07:58:44

标签: javascript jquery fullcalendar

在fullcalendar.js中,有一个函数renderSlatRowHtml

我正在尝试访问自己的角度组件打字稿文件。

下面是我正在尝试访问的代码

$('#calendar').fullCalendar({
   header: {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    },
    renderSlatRowHtml: function() {
     let view = this.view;
      let calendar = view.calendar;
      let theme = calendar.theme;
      let isRTL = this.isRTL;
      let dateProfile = this.dateProfile;
      let html = '';
      let slotTime = moment.duration(+dateProfile.minTime); // wish there was .clone() for durations
      let slotIterator = moment.duration(0);
      let slotDate; // will be on the view's first day, but we only care about its time
      let isLabeled;
      let axisHtml;

      // Calculate the time for each slot
      while (slotTime < dateProfile.maxTime) {
        slotDate = calendar.msToUtcMoment(dateProfile.renderUnzonedRange.startMs).time(slotTime);
        isLabeled = $('#calendar').isInt($('#calendar').divideDurationByDuration(slotIterator, this.labelInterval));

        axisHtml =
          '<td class="fc-axis fc-time' + theme.getClass('widgetContent testClass') + '" ' + view.axisStyleAttr() + '>' +
          (isLabeled ?
              '<span>' + // for matchCellWidths
              FC.htmlEscape(slotDate.format(this.labelFormat)) +
              '</span>' :
              ''
          ) +
          '</td>';

        html +=
          '<tr test data-time="' + slotDate.format('HH:mm:ss') + '"' +
          (isLabeled ? '' : ' class="fc-minor"') +
          '>' +
          (!isRTL ? axisHtml : '') +
          '<td class="' + theme.getClass('widgetContent testClass') + '"/>' +
          (isRTL ? axisHtml : '') +
          '</tr>';

        slotTime.add(this.slotDuration);
        slotIterator.add(this.slotDuration);
      }

      return html;
    }
 })

以上代码是从核心fullcalendar.js复制而来的。我正在尝试添加一些自定义类,例如testClass等。 但是没有用。

我正在使用完整日历版本:3.6.2

0 个答案:

没有答案