2012-05-13 20 views
0

確定即時通訊使用Adam Shaw的FullCalendar及其真正偉大的...我想獲得它的大部分功能。好。我的問題是我不能讓2個事件資源是我的頁面中存儲的window.initial_task_items和另一個是jquery.ajax函數的靜態JSON數據。JQuery完整日曆不能同時使用ajax事件資源和靜態資源

eventSources: [{ 
      //static events 
      events: window.initial_task_items}, 
     { //ajax fetching 
      events: function(start, end, callback) { 
       if (window.task_calendar_firstrun == true) { 
        window.task_calendar_firstrun = false; 
       } 
       else if (window.task_calendar_firstrun == false) { 
        window.AjaxRegistry["gettasks"] = $.ajax({ 
         url: window.cvars.userburl + "gettasks", 
         type: "GET", 
         dataType: 'json', 
         data: { 
          procdate: new XDate($('#task-full-calendar').fullCalendar('getDate')).toString("yyyy-MM-dd"), 
          user_hash: window.cvars.acuserhash 
         }, 
         beforeSend: function() { 

         }, 
         success: function(rsp) { 
          $('#task-full-calendar').fullCalendar('removeEvents'); 
          var events = []; 
          $.each(rsp, function(i, task) { 
           events.push({ 
            start: task.start, 
            end: task.end, 
            allDay: task.allDay, 
            title: task.title, 
            color: task.color 
           }); 
          }); 
          callback(events); 
         }, 
         error: function(ex) { 
          alert("error occured"); 
         }, 
         complete: function(obj, rsptype) { 

         } 
        }); 
       } 
      }}] 

現在我最近測試了上面的代碼,這不起作用。唯一的工作是ajax請求,當我單擊fullcalendar中的上一個和下一個按鈕時,但靜態JSON中的數據未呈現。

無論如何,我可以使兩個事件資源的工作?

注意: 我想加載我的頁面已經呈現在查看頁面時顯示的月份的任務。

回答

1

好吧,也許我不是很瞭解你的問題,但處理你的目的的方式就是這樣。

你必須在eventsources選項內通過所有的「源」(靜態和動態),而不是「覆蓋」像你這樣的事件所做的:

eventSources: [ 
    // 1. event source 
    array_of_static_events 
    // 2. event source 
    , { 
     url: "/getevents" 
     data: { param1: "test" } 
     error: function(){ alert("error"); } 
    } 
] // end of eventSources 

一切都進行了詳細的描述相關remote events,eventsource object

下面是一個正在運行的example,其中包含用於fullcalendar事件的靜態和遠程源文件。