How to block out dates in the Fullcalendar beyond a certain date

后端 未结 7 1144
心在旅途
心在旅途 2020-12-08 16:51

I have a date in the future which is always 30 days ahead of the current date. It\'s stored in a Date object. I worked this out using:

var currentDate = new          


        
7条回答
  •  执笔经年
    2020-12-08 17:37

    Use the dayRender option to add a "disabled" class to out of range dates.

    $('#calendar').fullCalendar({
        ...
        dayRender: function(date, cell){
            if (date > maxDate){
                $(cell).addClass('disabled');
            }
        }
        ...
    });
    

    You can also use the viewRender event and the gotoDate method, to prevent users to navigate farther than 30 days after today :

    $('#calendar').fullCalendar({
        ...
        viewRender: function(view){
            if (view.start > maxDate){
                $('#calendar').fullCalendar('gotoDate', maxDate);
            }
        }
        ...
    });
    

提交回复
热议问题