如何使用slotduration和slotLabelInterval中的自定义设置突出显示Fullcalendar中的周末

问题描述 投票:0回答:1

我具有自定义的slotDurationslotLabelInterval选项,因为我需要在一天中显示事件。但是,当我设置这些选项时,Fullcalendar不会在周末增加fc-satfc-sun类。无论如何我如何突出显示它们?

  firstDay: 1,
  slotWidth: 22,
  slotDuration: '12:00',
  slotLabelInterval: '24:00',
  slotLabelFormat: [{ weekday: 'short', day: 'numeric' }],

enter image description here

javascript jquery fullcalendar
1个回答
1
投票

我发现了一个肮脏的解决方法,但它可以工作。想法是通过标题中的日期名称选择span.fc-cell-text(在示例中使用捷克的日期名称),然后由其父项th.fc-widget-header获得其日期的日期值,然后仅添加一个类来突出显示整个列那个日期。因为一天之间相隔12个小时,所以也需要用T00:00:00T12:00:00时间突出显示日期。

$('span.fc-cell-text:contains("so "), span.fc-cell-text:contains("ne ")').each(function() {
    var date = $(this).parents('.fc-widget-header').data('date');
    $('td[data-date="' + date + '"], td[data-date="' + date.replace('T00:00:00', 'T12:00:00') + '"]').addClass('fc-sat');
 });

我想到的另一种解决方案是在周末的服务器端脚本中找到,但这实现起来更容易,更快捷。

© www.soinside.com 2019 - 2024. All rights reserved.