我正在使用完整的日历调度程序(1.6.2(,我正在从某个下拉列表中检索资源,并创建数组并馈送到完整的日历调度程序。在Firefox中成功添加资源,但在IE 11中仅添加了最后选择的下拉列表,下面是我的代码.我缺少什么或完整日历中是否有任何错误。
$("#schedule_employees > option:selected").each(function() {
var id = $(this).attr('id');
var title = $(this).text();
item = {}
item.id = id;
item.title = title;
employees.push(item);
employee2 = employee2 + $(this).attr('id') + ",";
});
if (employees.length == 0) {
alert("Please select the employees");
return false;
}
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar({
aspectRatio: '1',
height: "auto",
scrollTime: '00:00',
header: {
left: 'prev,next today',
center: 'title',
right: 'Schedule,agendaDays'
},
groupByResource: "true",
defaultView: 'Schedule',
titleRangeSeparator: ' - ',
allDaySlot: false,
timeFormat: 'HH:mm',
views: {
agendaDays: {
type: 'agenda',
slotLabelFormat: 'HH:mm',
//groupByDateAndResource: true,
groupByResource: true,
buttonText: 'Agenda 2 days',
duration: {
days: 2
},
},
Schedule: {
type: 'timeline',
slotDuration: '04:00:00',
slotLabelInterval: {
hours: 4
},
buttonText: 'Schedule',
visibleRange: {
start: moment($("#start_Date input").val(), 'MM/DD/YYYY HH:mm').format('YYYY-MM-DD'),
end: moment($("#end_Date input").val(), 'MM/DD/YYYY HH:mm').add(1, 'days').format('YYYY-MM-DD')
}
}
},
resourceLabelText: 'Employees',
resourceAreaWidth: '25%',
resources: employees,
viewRender: function(view, element) {
renderScheduleReport(employee2);
},
eventClick: function(event, jsEvent, view) {
alert("hi");
}
});
经过数小时的调试,我发现了哪里出了问题。在下面的循环中,员工数组每次迭代都包含相同的元素,替换现有的元素,因此在结束变量中包含相同的元素。不知道为什么IE总是惹麻烦。
$("#schedule_employees > option:selected").each(function() {
var id = $(this).attr('id');
var title = $(this).text();
将以下行从
item = {} //this is causing issue
到
var item = {};
item.id = id;
item.title = title;
employees.push(item);
employee2 = employee2 + $(this).attr('id') + ",";
});