我想在agendaWeek视图中显示displayEventEnd。默认情况下,它仅显示超过一小时的任何条目,但对于任何更少的条目,它只显示开始时间。是否有一种简单的方法可以显示此视图类型的较长和较短条目?
答案 0 :(得分:2)
使用eventAfterRender回调来更新标题。
eventAfterRender: function(event, $el, view) {
// only on agendaWeek view
if( 'agendaWeek' === view.name ) {
var formattedTime = $.fullCalendar.formatDates(event.start, event.end, "HH:mm { - HH:mm}");
// If FullCalendar has removed the title div, then add the title to the time div like FullCalendar would do
if($el.find(".fc-event-title").length === 0) {
$el.find(".fc-event-time").text(formattedTime + " - " + event.title);
}
else {
$el.find(".fc-event-time").text(formattedTime);
}
}
}
这是关于jsfiddle的一个例子:http://jsfiddle.net/kvakulo/zutPu/
答案复制自:Regin Larsen - Fullcalendar event's end time is missing
编辑:fullCalendar 2.8.0似乎HTML布局已更改。更新了小提琴和代码。
这是更新的小提琴:Updated fiddle fullCalendar 2.8.0
eventAfterRender: function(event, $el, view ) {
var formattedTime = $.fullCalendar.formatRange(event.start, event.end, "HH:mm");
// if event has fc-short class, data-start value will be displayed
// remove fc-short class and update fc-time span text
if($el.is('.fc-short') ) {
$el.find(".fc-time span").text(formattedTime + " - " + event.title);
$el.removeClass('fc-short');
$el.find('.fc-title').remove();
}
}