FullCalendar自定义/覆盖标题标题

编程入门 行业动态 更新时间:2024-10-11 21:20:21
本文介绍了FullCalendar自定义/覆盖标题标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想更改日历的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自定义/覆盖标题标题

本文发布于:2023-10-30 07:23:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542169.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标题   自定义   FullCalendar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!