0
我想添加一個數組的EventSource。我創建了一個字符串在一個Ajax callthat看起來是這樣的:Fullcalendar addEventSource Array
Public Shared Function Test() As String
Dim EventArray As New ArrayList
Dim EventSource As String = "[{"
EventSource += "title: 'All Day Event',"
EventSource += "start: '2012-07-01'"
EventSource += "},"
EventSource += "{"
EventSource += "title: 'Long Event',"
EventSource += "start: '2012-07-25',"
EventSource += "end: '2012-07-28'"
EventSource += "},"
EventSource += "{"
EventSource += "id: 999,"
EventSource += "title: 'Repeating Event',"
EventSource += "start: '2012-07-27 16:00:00',"
EventSource += "allDay: false"
EventSource += "},"
EventSource += "{"
EventSource += "id: 999,"
EventSource += "title: 'Repeating Event',"
EventSource += "start: '2012-08-04 16:00:00',"
EventSource += "allDay: false"
EventSource += "},"
EventSource += "{"
EventSource += "title: 'Meeting',"
EventSource += "start: '2012-07-30 10:30:00',"
EventSource += "allDay: false"
EventSource += "},"
EventSource += "{"
EventSource += "title: 'Lunch',"
EventSource += "start: '2012-07-30 12:00:00',"
EventSource += "end: '2012-07-30 14:00:00',"
EventSource += "allDay: false"
EventSource += "},"
EventSource += "{"
EventSource += "title: 'Birthday Party',"
EventSource += "start: '2012-07-31 19:00:00',"
EventSource += "end: '2012-07-31 22:30:00',"
EventSource += "allDay: false"
EventSource += "},"
EventSource += "{"
EventSource += "title: 'Click for Google',"
EventSource += "start: '2012-07-28',"
EventSource += "end: '2012-07-29',"
EventSource += "url: 'http://google.com/'"
EventSource += "}]"
Return EventSource
End Function
,我試圖加入數組是這樣的:
$(document).ready(function() {
$('#calendar').fullCalendar({
dayClick: function(date) {
alert(date);
},
editable: true
});
$.ajax({
type: 'POST',
url: 'KalenderEvents.aspx/Test',
data: '{}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
var events = msg.d || []
$('#calendar').fullCalendar('addEventSource','events:' + events);
$('#calendar').fullCalendar('rerenderEvents');
}
});
});
如果我刪除「事件:」代碼改掉執行一個JSON飼料... 別的他只是不顯示任何東西。 ajax調用正常執行。
這就是問題... 如果我只是給他的字符串: 「[{title:'titletext',start:'2012-03-05'},{...}]」 他trys to調用一個導致「NetworkError:400 Bad Request」的url ... 而我只是看不到我是(沒有?)出錯... =( – LightMonk 2012-07-30 13:42:26
您是否嘗試過使用'eventSources'?您可以使用在FullCalendar初始化時出現'$ .ajax' - http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/ 也許這樣可以解決這個問題 – ganeshk 2012-07-30 13:48:15
還不是,原因是我想添加/刪除來源於fullcalendar初始化 我現在嘗試它,只是爲了檢查它是否工作;-) – LightMonk 2012-07-30 13:54:21