javascript - How to use fullcalendar addeventsource with array? - Stack Overflow

Can you please say whats wrong with this? I have a javascript function called which creates a new event

Can you please say whats wrong with this? I have a javascript function called which creates a new events array and tries to refresh fullcalendar.

var events=new Array();
var numberofevents = this.serviceVariableGetDates.getTotal();

  for (i=0;i<numberofevents;i++)
       {
       //alert("numbrr:" + i);
       var dates=this.serviceVariableGetDates.getItem(i);
       console.log(dates.getData());
       var start_date = dates.getValue("c0");
       var end_date = dates.getValue("c1");
       var event_name = dates.getValue("c2");
       //var EventEntry = [ 'title: '+ event_name, 'start: '+ start_date,'end: '+ end_date ];
       events['title'] = event_name;
       events['start'] = start_date;
       events['end'] = end_date;
       events['color'] = "blue";
       this.label1.setCaption(start_date);
       //EventArray.push(EventEntry);
       console.log(events['title']);
       }
  $('#calendar').fullCalendar('addEventSource',events);
  $('#calendar').fullCalendar('rerenderEvents');

The calendar does not refresh or show the events in the events array....Through different debug methods I am sure that the events array is populated with the correct data. The start_date is for example "1307318400000" which is in the unix timestamp format. The fullcalendar is being initialized somewhere else in the begining (when the page load) and it stays unchanged even though addeventsource and rerenderevents methods are called.

Can you please say whats wrong with this? I have a javascript function called which creates a new events array and tries to refresh fullcalendar.

var events=new Array();
var numberofevents = this.serviceVariableGetDates.getTotal();

  for (i=0;i<numberofevents;i++)
       {
       //alert("numbrr:" + i);
       var dates=this.serviceVariableGetDates.getItem(i);
       console.log(dates.getData());
       var start_date = dates.getValue("c0");
       var end_date = dates.getValue("c1");
       var event_name = dates.getValue("c2");
       //var EventEntry = [ 'title: '+ event_name, 'start: '+ start_date,'end: '+ end_date ];
       events['title'] = event_name;
       events['start'] = start_date;
       events['end'] = end_date;
       events['color'] = "blue";
       this.label1.setCaption(start_date);
       //EventArray.push(EventEntry);
       console.log(events['title']);
       }
  $('#calendar').fullCalendar('addEventSource',events);
  $('#calendar').fullCalendar('rerenderEvents');

The calendar does not refresh or show the events in the events array....Through different debug methods I am sure that the events array is populated with the correct data. The start_date is for example "1307318400000" which is in the unix timestamp format. The fullcalendar is being initialized somewhere else in the begining (when the page load) and it stays unchanged even though addeventsource and rerenderevents methods are called.

Share Improve this question asked May 31, 2011 at 3:48 Johnny DepJohnny Dep 311 gold badge1 silver badge3 bronze badges 1
  • Rendering the event feed as an array is not remended- Even the author talk about this and encourages server side feed using json replies. Managing the arrays on the client can be very difficult. arshaw./fullcalendar/docs/event_data/events_array – Piotr Kula Commented May 31, 2011 at 15:24
Add a ment  | 

1 Answer 1

Reset to default 4

according to the docs you need to put array of events to the addEventSource function

event must be an Event Object with a title and start at the very least.

var events=new Array();
var numberofevents = this.serviceVariableGetDates.getTotal();
    for (i=0;i<numberofevents;i++)
    {
    //alert("numbrr:" + i);
    var dates=this.serviceVariableGetDates.getItem(i);
    console.log(dates.getData());
    var start_date = dates.getValue("c0");
    var end_date = dates.getValue("c1");
    var event_name = dates.getValue("c2");
    //var EventEntry = [ 'title: '+ event_name, 'start: '+ start_date,'end: '+ end_date ];
    event = new Object();       
    event.title = event_name; // this should be string
    event.start = start_date; // this should be date object
    event.end = end_date; // this should be date object
    event.color = "blue";
    event.allDay = false;
    this.label1.setCaption(start_date);
    //EventArray.push(EventEntry);
    console.log(events['title']);
    events.push(event);
    }
$('#calendar').fullCalendar('addEventSource',events);
//$('#calendar').fullCalendar('rerenderEvents');

Hope this will help!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744282138a4566621.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信