2011-10-15 30 views
1

我知道有一個如何使用多個進料源與FullCalendar幾個例子,即: Stackoverflow post多eventsources使用jQuery FullCalendar

Plugin Docs

然而,他們沒有說明如何使用多個進料源與額外的ajax信息,如類型,數據等

我想使用多個飼料來源,但不能得到它的工作。這裏是我的代碼:

eventSources: [ 
    'json-schedule.php', 
    'json-events.php' 
], 

    type: 'POST', 
    data: { 
     // custom_param1: 'something', 
    }, 
    error: function() { 
     alert('there was an error while fetching events!'); 
    }, 
    success: function() { 
    }, 

哪裏的類型,數據,錯誤&成功零件與多個數據源去?我找到的例子都沒有證明這一點。

回答

2

嘗試這種方式:

$('#calendar').fullCalendar({ 
    ... 
    eventSources: [ 
     // your JSON event source 
     { 
      url: '/myfeed.php', // use the `url` property 
      color: 'yellow', // an option! 
      textColor: 'black' // an option! 
     }, 

     // your ajax event source 
     { 
      events: function(start, end, callback) { 
       $.ajax({ 
        url: 'myxmlfeed.php', 
        dataType: 'xml', 
        data: { 
         // our hypothetical feed requires UNIX timestamps 
         start: Math.round(start.getTime()/1000), 
         end: Math.round(end.getTime()/1000) 
        }, 
        success: function(doc) { 
         var events = []; 
         $(doc).find('event').each(function() { 
         events.push({ 
          title: $(this).attr('title'), 
          start: $(this).attr('start') // will be parsed 
         }); 
        } 
       }); 
      } 
     } 
    ], 
    ... 
}); 
+0

這個例子是直接從文件取出,[這裏](http://arshaw.com/fullcalendar/docs/event_data/events_function/) – allicarn

0
eventSources: [ 
      { 
       url: 'json-schedule.php', 
       type: 'POST', 
       data: { 
        date: start, //data to be sent 
        custom_param2: 'somethingelse' 
       }, 
       error: function() { 
        alert('there was an error while fetching shedule!'); 
       }, 
       color: 'yellow', // a non-ajax option 
       textColor: 'black' // a non-ajax option 
      }, 
      { 
       url: 'json-events.php', 
       type: 'POST', 
       /*data: { 
        custom_param1: 'something', 
        custom_param2: 'somethingelse' 
       },*/ 
       error: function() { 
        alert('there was an error while fetching events!'); 
       }, 
       color: 'green', // a non-ajax option 
       textColor: 'black' // a non-ajax option 
      } 
     ],