如果有活动,请查看日历

时间:2016-03-04 20:48:59

标签: javascript jquery fullcalendar

我正在网站上为朋友工作,并想知道是否有办法在jQuery插件FullCalendar中检查今天是否有活动。如果今天有一些事件,那么显示basicDay日历,否则隐藏日历?或者,如果没有这个,它可以将basicDay日历关注日历中的下一个事件(如果有的话)。

1 个答案:

答案 0 :(得分:0)

你去了:

// Initiate a variable that tells that there is no event today
var hasAnEventToday = false;

//We'll create a variable for today
var today = new Date();

//First, you store your events in a variable
var events = $('#calendar').fullCalendar('clientEvents');

// Loop trough the event to see if there is at least one with your date
$.each(events, function(){ 
  var testedDate = new Date($(this)[0].start._i); 
  if (today == testedDate){
    hasAnEventToday = true;
  }
});

if (hasAnEventToday){
   // Do your logic
}