FullCalendar Custom/Override Header title

馋奶兔 提交于 2019-12-02 04:23:08

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.).

A simple way is to overwrite the view.title within the viewRender event:

...
,
header: {
  center: 'title',
},
viewRender: function(view, element) {
  view.title = 'Your Custom Title';
},
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!