Fullcalendar: dayClick -> gotoDate -> changeView doesn't work as expected

Created on 6 Apr 2017  路  4Comments  路  Source: fullcalendar/fullcalendar

Hi!
I usually used the dayClick callback to show the current day in this way:

dayClick: function (date, ....) {
$('#calendar').fullCalendar('gotoDate', date);
$('#calendar').fullCalendar('changeView', 'agendaDay');
}

This works fine in 3.2.0

Behavior in 3.3.1 is: no matter which day I click 'today' is shown.

Pls. verify here: https://jsfiddle.net/vonboth/01ur7a9a/

Most helpful comment

I had same problem. There are two fixes for it:

dayClick: function (date, ....) {
    $('#calendar').fullCalendar('changeView', 'agendaDay', date);
}

or just reorder your statments

dayClick: function (date, ....) {
    $('#calendar').fullCalendar('changeView', 'agendaDay');
    $('#calendar').fullCalendar('gotoDate', date);
}

All 4 comments

This does looks like a bug with gotoDate not accepting the moment object from the dayClick callback.

BTW you might want to specify the date in the changeView instead of doing both gotoDate and changeView: https://fullcalendar.io/docs/views/changeView/

I was having the same issue, and using "changeView" to do both fixed the problem.

It should be documented as a breaking change tough.

I had same problem. There are two fixes for it:

dayClick: function (date, ....) {
    $('#calendar').fullCalendar('changeView', 'agendaDay', date);
}

or just reorder your statments

dayClick: function (date, ....) {
    $('#calendar').fullCalendar('changeView', 'agendaDay');
    $('#calendar').fullCalendar('gotoDate', date);
}

or call changeView with the new view name and the new date. see example at bottom:
https://fullcalendar.io/docs/views/changeView/

Was this page helpful?
0 / 5 - 0 ratings