Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FullCalendar Modify Header on Resize

I'm using FullCalendar and I'm attempting to make it responsive by changing the view when the window size is below a certain size:

windowResize : function(view) {
    if ($(window).width() < 500) {
        $('#calendar').fullCalendar('changeView', 'basicDay');
    } else {
        $('#calendar').fullCalendar('changeView', 'month');
    }
    // modify the header (remove options for month and week and remove title)
}

That works fine but how can I modify the header (remove options for month and week and remove title)? You can see an example of the calendar here.

Header is set as such:

$('#calendar').fullCalendar({
    header : {
        left : 'prev,next today',
        center : 'title',
        right : 'month,basicWeek,basicDay'
    }
});
like image 600
SeanWM Avatar asked Mar 03 '26 09:03

SeanWM


1 Answers

I needed a responsive script too, but the best i get was:

var view = 'month';
var header = {
            left : "title",
            center : "",
            right : "prev,next month,basicWeek,basicDay today"
    };
if ($(window).width() <= 480) {
    view = 'basicDay';
    header = {
        left : 'prev,next today',
        center : '',
        right : ''
    };
}
var acalendar = $("#ccalendar").fullCalendar(
            {
                            lang : "pt-BR",
                            defaultView : view,
                            header : header
             }

Maybe you can rebuild de calendar on resize.

like image 99
Victor Pinto Avatar answered Mar 06 '26 00:03

Victor Pinto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!