In this post, we will learn how to change a calendar's view so that when we click the MonthView date, it redirects to the WeekView and goes back to the MonthView when clicked again. Here is a simple jQuery code for doing this action.
Write the below code in dayClick for changing the view of the calendar.
Write the below code in eventClick for changing the view of the calendar.
- dayClick: function(date, jsEvent, view) {
- $('#calendar').fullCalendar('gotoDate',date);
- $('#calendar').fullCalendar('changeView','agendaWeek');
- },
- eventClick: function(calEvent, event, jsEvent) {
- var dt = calEvent.start;
- $('#calendar').fullCalendar('gotoDate',dt);
- $('#calendar').fullCalendar('changeView','agendaWeek');
- }
- var view = $('#calendar').fullCalendar('getView');
- alert(view.name == 'month');
- {
- $('#calendar').fullCalendar('gotoDate', date);
- $('#calendar').fullCalendar('changeView', 'agendaWeek');
- }

Join the conversation! Your thoughts help the community grow.