2012-07-30 80 views
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调用正常执行。

回答

0

您不需要在addEventSource中使用events:。 FullCalendar应该正确接受一个JSON数组。

+0

这就是问题... 如果我只是给他的字符串: “[{title:'titletext',start:'2012-03-05'},{...}]” 他trys to调用一个导致“NetworkError:400 Bad Request”的url ... 而我只是看不到我是(没有?)出错... =( – LightMonk 2012-07-30 13:42:26

+0

您是否尝试过使用'eventSources'?您可以使用在FullCalendar初始化时出现'$ .ajax' - http://arshaw.com/fullcalendar/docs/event_data/events_json_feed/ 也许这样可以解决这个问题 – ganeshk 2012-07-30 13:48:15

+0

还不是,原因是我想添加/删除来源于fullcalendar初始化 我现在尝试它,只是为了检查它是否工作;-) – LightMonk 2012-07-30 13:54:21