2016-05-11 31 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); 
      } 
     }); 
    } 
}); 
使用下面的方法