2016-05-11 34 views
0

我正在使用fullcalendar在我的Web應用程序中呈現事件。我從服務器使用下面的方法將事件添加到從服務器返回的事件數組FullCalendar

events: { 
      url: '/api/availability/events', 
      error: function() { 
       //alert("some error fetching events"); 
      } 
     } 

事件返回並通過完整的日曆呈現精細,這裏是日曆中的那些事件的看法得到事件的JSON提要。 Current View of Full Calendar
要求是顯示每天哪個服務器沒有返回任何事件的默認事件。就像我想在標題爲Available for All meals的每個空單元上顯示事件。

而要求是這應該在客戶端完成,服務器應該不知道有關默認事件。所以我的問題是,如何從服務器返回它後更改事件數組,並在每個空閒日(空白日=沒有事件的日)添加默認事件。

回答

0

我結束了從fullcalendar documentation

$('#calendar').fullCalendar({ 
    events: function(start, end, timezone, callback) { 
     $.ajax({ 
      url: 'myxmlfeed.php', 
      dataType: 'xml', 
      data: { 
       // our hypothetical feed requires UNIX timestamps 
       start: start.unix(), 
       end: end.unix() 
      }, 
      success: function(doc) { 
       var events = []; 
       $(doc).find('event').each(function() { 
        events.push({ 
         title: $(this).attr('title'), 
         start: $(this).attr('start') // will be parsed 
        }); 
       }); 
       //append custom events here 
       callback(events); 
      } 
     }); 
    } 
}); 
使用下面的方法