我想更改日历的titleFormat。
目前,标题为h2标签,我们无法通过向titleFormat选项添加html代码来实现个性化。 例如把一个span标签放在我的titleFormat(它是[]那里的固定值)。
我想知道是否有可能覆盖类Header的updateTitle方法,而不修改fullcalendar.js。或者另一种可能性。
我有两种观点:标题格式为'[Semaine] W'的星期和标题格式为'dddd D MMMM YYYY'的自定义一天。 p>
我的FullCalendar版本是v2.3.0。
解决方案好的,这个并不是真的被支持,但这是一个解决方法。 JSFiddle
viewRender:function(view,element){ //标题在回调之后才会呈现,所以我们需要使用超时。 if(view.type ===agendaWeek){ window.setTimeout(function(){ $(#calendar)。find('。fc-toolbar> div> h2')。empty()。append(< div>+ view.start.format('MMM Do [to]')+< / div>+ < div>+ view.end.format('MMM Do')+< / div>); },0); } else if(view.type ===agendaDay){ window.setTimeout(function(){ $(#calendar)。find('。fc-toolbar > div> h2')。empty()。append(< div>+ view.start.format('dddd D MMMM YYYY')+< / div>); },0); } },我不知道它是否最稳定但在最糟糕的情况下,它可能会有一些微妙的美学错误(比如新版FC版本发布时)。
I want change the titleFormat of my calendar.
At present, the title is in an h2 tag and we cannot personalize it by adding html code to the titleFormat option. For example put a span tag on my fixed value of the titleFormat (which is [] there).
I would want to know if it is possible to override the updateTitle method of the class Header, without modifying fullcalendar.js. Or another possibility.
I have 2 views : week with title format '[Semaine] W' and custom one Day with title format 'dddd D MMMM YYYY'.
My version of FullCalendar is v2.3.0.
解决方案Okay, this isn't really supported but here's a workaround. JSFiddle
viewRender: function (view, element) { //The title isn't rendered until after this callback, so we need to use a timeout. if(view.type === "agendaWeek"){ window.setTimeout(function(){ $("#calendar").find('.fc-toolbar > div > h2').empty().append( "<div>"+view.start.format('MMM Do [to]')+"</div>"+ "<div>"+view.end.format('MMM Do')+"</div>" ); },0); }else if(view.type === "agendaDay"){ window.setTimeout(function(){ $("#calendar").find('.fc-toolbar > div > h2').empty().append( "<div>"+view.start.format('dddd D MMMM YYYY')+"</div>" ); },0); } },I don't know if it's the most stable thing in the world but, at worst, it might have a slight aesthetic glitch sometimes (like when a new FC version gets released.).
更多推荐
FullCalendar自定义/覆盖标题标题
发布评论