java按钮数组添加事件_fullcalendar addEventSource不将事件数组添加到日历

我正在创建一个通话时间表,用户可以在其中选择具有成员列表以及轮换长度和类型的组 . 当用户单击“创建计划”按钮时,将在表示此轮换计划的日历上显示事件列表 . 事件已创建并添加到事件数组中,但它们不会显示在日历上 . 当代码到达时,

$('#edit_calendar').fullCalendar('addEventSource', newEvents);

应用程序只挂起,日历上不显示任何事件 . 这是为click事件调用的函数:

$("#rotation_schedule_btn").click(function () {

//create member list order

var memberList = [];

$("#rotationList li").each(function () {

memberList.push({

id: $(this).attr('id'),

name: $(this).text(),

color: $(this).css('background-color')

})

});

//start and end date and time for new schedule

var startDate = new Date($('#schedule_start_date').val());

var endDate = new Date($('#schedule_end_date').val());

//remove events between startDate & endDate

$('#edit_calendar').fullCalendar('removeEvents', function (event) {

if (event.start.toDate() >= startDate && event.start.toDate() <= endDate

|| event.end.toDate() >= startDate && event.end.toDate() <= endDate) {

return true;

}

});

//Create events from rotation schedule selected

var newEvents = [];

var rotation_length = $('#rotation_type_select option:selected').val();

var rotation_start_date = new Date(startDate);

var rotation_end_date = new Date(rotation_start_date);

rotation_end_date.setDate(rotation_end_date.getDate() + parseInt(rotation_length));

rotation_end_date.setMinutes(rotation_end_date.getMinutes() - 1);

var member_index = 0;

while (rotation_end_date <= endDate)

{

var event = new Object();

event = {

title: memberList[member_index].name,

start: rotation_start_date,

end: rotation_end_date,

objectID: memberList[member_index].id,

color: memberList[member_index].color,

allDay: true,

textColor: 'black'

};

newEvents.push(event);

rotation_start_date.setDate(rotation_start_date.getDate() + parseInt(rotation_length));

rotation_end_date.setDate(rotation_end_date.getDate() + parseInt(rotation_length));

if ((memberList.length - 1) == member_index)

{

member_index = 0;

}

else {

member_index++;

}

}

//Render events on calendar

$('#edit_calendar').fullCalendar('addEventSource', newEvents);

}); //end create schedule button click

为什么newEvents数组不会显示在日历上?如果你能告诉我哪里出错了,我将不胜感激 .

谢谢 .

UPDATE 在查看newEvents数组之后,似乎所有的开始和结束日期都是相同的 . 有3个事件,每个事件应持续1周(7天) . 但是所有事件都有相同的开始和结束日期 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值