You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整FullCalendar事件显示顺序:标题前置时间?(指定代码段修改)

Fixing FullCalendar Event Display: Title First, Time Second

Got it, let's adjust that event text order so your "7a Birthday Party" becomes "Birthday Party 7a". Here's exactly how to tweak the code in lines 14475-14495 of fullcalendar.js:

Step 1: Locate the Text Concatenation Logic

First, find the section in those lines where the event time and title are being stitched together. It’ll look something like this (varies slightly by FullCalendar version, but the core idea is the same):

// Original code (example from your target line range)
var timeStr = this.formatTime(event.start, event.end, this.opt('timeFormat'));
var titleStr = event.title || '';
var displayText = timeStr + ' ' + titleStr; // Time first, title second
// Then this displayText gets inserted into the event element
$(eventEl).html(displayText);

Step 2: Swap the Order of Title and Time

All you need to do is reverse the order of the variables in the concatenation line. Also, add a quick check to avoid extra spaces if the event has no title:

// Modified code
var timeStr = this.formatTime(event.start, event.end, this.opt('timeFormat'));
var titleStr = event.title || '';
// Swap title and time, handle empty title case
var displayText = titleStr ? (titleStr + ' ' + timeStr) : timeStr;
// Keep the DOM insertion line the same
$(eventEl).html(displayText);

Quick Notes

  • If your exact code uses different variable names (like eventText instead of displayText), just adjust to match what’s in your file—look for where the time string and title string are combined.
  • Double-check that you’re modifying the right block: it should reference event.title and formatTime/timeFormat, since those are the pieces we’re reordering.

内容的提问来源于stack exchange,提问作者user51395rk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:16:37