javascriptajaxfullcalendarfullcalendar-3

How to use Custom button only for month view in JavaScript full calendar?


I added custom button in my JavaScript full calendar code but I want to show this button only month view.

$(document).ready(function() {

  var calendar = $('#calendar').fullCalendar({

    editable: true,
    //FOR HEADER

    header: {
      left: ' prev,next today ',
      center: 'title',
      right: 'month,agendaDay,agendaWeek,myCustomButton'
    },
    customButtons: {
      myCustomButton: {
        text: 'REPEAT FOR NEXT MONTH',
        click: function() {
          alert('my custom button');
        }
      }
    }

  });

});

Solution

  • If you need to append button for each day in a month view then you may use the following snippet:-

    eventAfterAllRender: function(view) {
    
       if(view.name == 'month')
       {                       
           $('.fc-day').each(function(){
              $(this).append('<button>Day</button>');
           });      
        }
    }