Fullcalendar slotMinutes不起作用

Ric*_*ata 2 jquery fullcalendar

我想为我的日历显示15的slotMinutes.但它不起作用.它适用于这个小提琴

$(document).ready(function() {

  var calendar = $('#calendar').fullCalendar({
  defaultView: 'agendaWeek',
  editable: true,
  slotMinutes: 15,
  selectable: true,
  //header and other values
  select: function(start, end, allDay) {
      endtime = $.fullCalendar.formatDate(end,'h:mm tt');
      starttime = $.fullCalendar.formatDate(start,'ddd, MMM d, h:mm tt');
      var mywhen = starttime + ' - ' + endtime;
      $('#createEventModal #apptStartTime').val(start);
      $('#createEventModal #apptEndTime').val(end);
      $('#createEventModal #apptAllDay').val(allDay);
      $('#createEventModal #when').text(mywhen);
      $('#createEventModal').modal('show');
   }
});
Run Code Online (Sandbox Code Playgroud)

要访问小提琴,请单击http://jsfiddle.net/mccannf/AzmJv/16/ ...但是,它不适用于我的,我做错了什么?

Luí*_*ruz 15

你正在比较v1的小提琴和你的v2小提琴.

在v2中没有slotMinutes.相反,你应该使用slotDuration(参见文档),应该设置为:

slotDuration: '00:15:00'
Run Code Online (Sandbox Code Playgroud)

这是更新的jsfiddle.

编辑:在垂直轴上添加每个时隙的描述

前一个小提琴显示15分钟的插槽,但垂直轴只有小时(如早上6点,早上7点等).

如果您希望垂直轴具有所有时隙(早上6点,上午6点15分,上午6点半,早上6点45分),您可以检查第fullcalendar.js5780行(版本2.1.1)的源代码,其中有一个函数被调用slatRowHtml.

在此函数中,以下条件用于写入时间:!slotNormal || !minutes,其中:

var slotNormal = this.slotDuration.asMinutes() % 15 === 0;
minutes = slotDate.minutes();
Run Code Online (Sandbox Code Playgroud)

所以,slotNormal总是被真(我们设定15分钟时间),并minutes0,15,3045.由于条件为负(!slotNormal || !minutes),这意味着它!slotNormal总是false并且仅在时间!minutes时才为真minutes = 0,这就是为什么只显示小时数.

要解决此问题,您有两个选项,每个选项都有其怪癖:

  1. 设置slotNormal = '00:15:01'.使用此值slotNormal将为false,并且所有插槽都将具有描述.这个问题是你要为每个时隙添加一秒,这意味着,当fullcalendar打印时3pm,它将是3:01pm因为增加的秒数.你可以查看这个JSFiddle.
  2. 从源代码中删除整个条件并保留slotDuration = '00:15:00'.这将有效,但您需要记住每次更新FullCalendar时检查条件,