本文介绍了Fullcalendar限制可用月份的显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何限制fullcalendar显示三个月的时间,并在日期选择器内的其余月份取消选择?

例如,当前月份是2010年5月份,我只希望日历显示5月和4月(单击上个月),Jun(单击下月),其余月份将从用户选择中取消选择。



我不确定是否错过了阅读fullcalendar文档的任何部分。好心提醒。谢谢。

解决方案

For FullCalendar in version 2 change viewDisplay:function(view){
viewRender:function(view,element){(此页面示例中的混合解决方案):
$ fullCalendar({

//将可用日期限制在将来的2个月以后
viewRender:
$ $ $ $''code $('#calendar' function(view,element){
var now = new Date();
var end = new Date();
end.setMonth(now.getMonth()+ 2); //根据需要调整

if(end< view.end){
$(#calendar .fc-next-button)。hide();
return false;

$ {
$(#calendar .fc-next-button)。show();
}

if(view。开始< now){
$(#calendar .fc-prev-button)。hide();
return false;
}
else {
$(#calendar .fc-prev-button)。show();
}
}
});


I would like to find out how can I limit the fullcalendar to show a three months period and deselectable for the rest of the months like within a datepicker?

E.g. The current month is May 2010, I would only like the calendar to show May and Apr (on clicking of previous month), and Jun (on clicking on next month), the rest of the months would be deselected from user selection.

I am not sure if I missed reading any part on the fullcalendar documentation. Kindly advise. Thank you.

解决方案

For FullCalendar in version 2 change viewDisplay : function(view) { toviewRender: function(view,element) { (mixed solution from examples at this page):

  $('#calendar').fullCalendar({

       //restricting available dates to 2 moths in future
        viewRender: function(view,element) {
            var now = new Date();
            var end = new Date();
            end.setMonth(now.getMonth() + 2); //Adjust as needed

            if ( end < view.end) {
                $("#calendar .fc-next-button").hide();
                return false;
            }
            else {
                $("#calendar .fc-next-button").show();
            }

            if ( view.start < now) {
                $("#calendar .fc-prev-button").hide();
                return false;
            }
            else {
                $("#calendar .fc-prev-button").show();
            }
        }
  });

这篇关于Fullcalendar限制可用月份的显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 23:11