6
votes

I am using full calendar. here my question is how to find the fullcalendar is in month view, week view or day view in format when clicking prev button or next button clicking function. here am calling custom code for next and prev buttons. because using this I want to fire some custom data. based on fullcalendar view.

 $(document).on('click', '.fc-button-next a span', function () {

here I want to find the view of full calendar which is in month or week or day

       var abc = $("#calendar").fullCalendar('getView').start.toString();
       var MonthVal = getMonthValue(abc);
       var YearVal = getYearValue(abc);

       $('#calendar').fullCalendar('destroy');

       dataString = "{ID:" + MonthVal + "," + "year:" + YearVal + "}";

       DisplayCalendarForMonth(dataString, MonthVal, YearVal);
   });
   $(document).on('click', '.fc-button-today a span', function () {

here I want to find the view of full calendar which is in month or week or day

       $('#calendar').fullCalendar('destroy');
       DisplayCalendar();
   });
4

4 Answers

8
votes
 var view = $('#calendar').fullCalendar('getView');
if (view.name == 'month') {
}
1
votes
$('#calendar').fullCalendar({
    viewDisplay: function(view) {
      alert('The new title of the view is ' + view.title);

      // view consist Available views
      // month, basicWeek,basicDay,agendaWeek,agendaDay
    }
});
1
votes
 var view = $('#calendar').fullCalendar('getView');

not working for me, instead I use:

var calendar = new FullCalendar.Calendar(document.getElementById('calendar'), {
  ...
}

console.log(
  calendar.view.type
);

Console prints: dayGridMonth

-1
votes
 var view = $('#calendar').fullCalendar('getView');
 alert("You have click on"+view.name);

ref link: enter link description here