[Solved] Show only one month name in FullCalendar when WeekView wraps two different months


This isn’t directly supported unfortunately, but there is still a better way than modifying the FC source (that get’s messy with patches and stuff).

There are several render hooks available that we can use to fix the formatting after the fact. viewRender doesn’t work because it’s called before the title changes. So we can use eventAfterAllRender instead.

eventAfterAllRender:function(){
    if(view.name!=="agendaWeek")
        return;
    var $title = $("#calendar").find(".fc-toolbar h2"); //Make sure this is the right selector
    var text = $title.text();
    text = text.match(/.*? /)+text.match(/[0-9]+/);
    $title.text(text); //replace text
}

JSFiddle – titleFormat hack

Not the most elegant thing in the world, but it should work better than modifying the source. Let me know if there are any issues.

Edit:

Also, if you’re having problems with it flashing the wrong dateformat before the correct one, use css the make the title invisible. Then add a class to the element in eventAfterAllRender that makes it visible again.

10

solved Show only one month name in FullCalendar when WeekView wraps two different months