我正在尝试使用jMonthCalendar将XML Feed中的一些事件添加到日历中。在原来的jMonthCalendar,该事件是一个数组,看起来像这样:我怎样才能得到这个字符串转换回数组?
var events = [
{ "EventID": 1, "StartDateTime": new Date(2009, 5, 12), "Title": "10:00 pm - EventTitle1", "URL": "#", "Description": "This is a sample event description", "CssClass": "Birthday" },
{ "EventID": 2, "StartDateTime": "2009-05-28T00:00:00.0000000", "Title": "9:30 pm - this is a much longer title", "URL": "#", "Description": "This is a sample event description", "CssClass": "Meeting" }];
我使用一个循环来创建这样一串事件:
eventsArray += '{"EventID":'+eventID+', "StartDateTime": '+new Date(formattedDate)+', "EndDateTime": '+new Date(formattedDate)+', "Title": "'+eventTitle+'", "URL": "'+detailURL+'","Description": "'+description+'"},'
然后我试图让这些回的阵列通过执行
eventsArray = eventsArray.slice(0, -1); var events = [eventsArray];
的问题是,在“eventsArray”的东西没有得到转化回阵列对象,如它在例如源一样。
我知道这是一个noob问题,但任何帮助,将不胜感激。
哇,谢谢!我结束了使用推,而不是追加,但真棒的答案。谢谢! – mrr0ng 2010-07-08 23:01:51