How To Redirect MonthView To WeekView Of Specific Date In jQuery Calendar

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.
  1. dayClick: function(date, jsEvent, view) {  
  2.      $('#calendar').fullCalendar('gotoDate',date);  
  3.      $('#calendar').fullCalendar('changeView','agendaWeek');  
  4. }, 
Write the below code in eventClick for changing the view of the calendar.
  1. eventClick: function(calEvent, event, jsEvent) {   
  2.      var dt = calEvent.start;   
  3.      $('#calendar').fullCalendar('gotoDate',dt);   
  4.      $('#calendar').fullCalendar('changeView','agendaWeek');   

Below is the sample code for checking the View name. Add this code to the above event code and you will get the View name.
  1. var view = $('#calendar').fullCalendar('getView');  
  2.   
  3. alert(view.name == 'month');  
  4. {  
  5.     $('#calendar').fullCalendar('gotoDate', date);  
  6.     $('#calendar').fullCalendar('changeView''agendaWeek');  
  7. }