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

后端 未结 7 1161
心在旅途
心在旅途 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 17:30

    this one chose the current month period

    
    $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next',
                    center: 'title',
                    right: 'today'
                },
                defaultDate: moment(),
                editable: false,
                //height:'auto',
                //weekends: false,
                defaultView: 'agendaWeek', 
                eventLimit: true, 
    
                events: {
                    url: 'php/get-events.php',
                    error: function() {
                        $('#script-warning').show();
                    }
    
                },
                loading: function(bool) {
                    $('#loading').toggle(bool);
    
                },
            viewRender: function(view,element) {
                var now = new Date();
                var end = new Date();
                end.setMonth(now.getMonth()); 
                end.setDate();
                now.setDate(1);
                if ( end < view.end) {
                    $("#calendar .fc-next-button").hide();
                    return false;
                    alert(end);
                }
                else {
                    $("#calendar .fc-next-button").show();
                }
    
                if ( view.start < now) {
                    $("#calendar .fc-prev-button").hide();
                    return false;
                }
                else {
                    $("#calendar .fc-prev-button").show();
                }
            }
            });
        });
    

提交回复
热议问题