如何使用 slotduration 和 slotLabelInterval 中的自定义设置在 Fullcalendar 中突出显示周末
How to highlight weekends in Fullcalendar with custom settings in slotduration and slotLabelInterval
我有选项 slotDuration
和 slotLabelInterval
自定义,因为我需要在一天中显示事件。但是当我设置这些选项时,Fullcalendar 不会将 fc-sat
和 fc-sun
类 添加到周末。我怎样才能突出显示它们?
firstDay: 1,
slotWidth: 22,
slotDuration: '12:00',
slotLabelInterval: '24:00',
slotLabelFormat: [{ weekday: 'short', day: 'numeric' }],
我找到了一个肮脏的变通解决方案,但它有效。这个想法是 select span.fc-cell-text
通过 header 中的日期名称(例如使用捷克日期名称),然后通过其 parent th.fc-widget-header
得到一个其日期的日期值,然后只需添加 class 即可突出显示该日期的整个列。因为一天相隔 12 小时,所以需要用 T00:00:00
和 T12: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');
});
我想到的另一个解决方案是通过 server-side 脚本周末找到,但这更容易和更快地实施。
我有选项 slotDuration
和 slotLabelInterval
自定义,因为我需要在一天中显示事件。但是当我设置这些选项时,Fullcalendar 不会将 fc-sat
和 fc-sun
类 添加到周末。我怎样才能突出显示它们?
firstDay: 1,
slotWidth: 22,
slotDuration: '12:00',
slotLabelInterval: '24:00',
slotLabelFormat: [{ weekday: 'short', day: 'numeric' }],
我找到了一个肮脏的变通解决方案,但它有效。这个想法是 select span.fc-cell-text
通过 header 中的日期名称(例如使用捷克日期名称),然后通过其 parent th.fc-widget-header
得到一个其日期的日期值,然后只需添加 class 即可突出显示该日期的整个列。因为一天相隔 12 小时,所以需要用 T00:00:00
和 T12: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');
});
我想到的另一个解决方案是通过 server-side 脚本周末找到,但这更容易和更快地实施。