nikolas
nikolas

Reputation: 722

FullCalendar select day in month returns incorrect week

I have an implementation of the fullcalendar in yii installation. I use three options month,agendaWeek.agendaDay The problem is, that when i am in the month display and i select a day, the agendaWeek that loads is usually the previous week from the the actually picked.

        'dayClick' => new CJavaScriptExpression("function(date, jsEvent, view) {
                        var currdisplay=view.name;
                        if(currdisplay=='month'){  
                            $('.calendar').fullCalendar( 'changeView', 'agendaWeek'  );
                        }}"),

the options that i have set are

'options'=>array(
        'header'=>array(
        'left'=>'prev,next,today',
        'center'=>'title',
        'right'=> 'month,agendaWeek,agendaDay',
    ),
    'minTime' => '09:00:00',
    'maxTime' => '20:00:00',
    'slotDuration' => '01:00:00',
    'slotEventOverlap' => false,
    'defaultTimedEventDuration' => '01:00:00',
    'allDaySlot' => false,
    'allDay' => false,
    'lazyFetching'=>true,
    'weekends' => false,
    'selectable' => true,
    'height' => 'auto',
)

FullClendar version 2.1.1

Upvotes: 0

Views: 498

Answers (1)

Try actually changing the date to the one the user clicked on before changing view.

$('#calendar').fullCalendar({
    dayClick: function(date, jsEvent, view) {
        if(view.name == 'month') {
            $('#calendar').fullCalendar('gotoDate', date);
            $('#calendar').fullCalendar('changeView', 'agendaWeek');
        }
    }
    ...
});

Upvotes: 1

Related Questions