本文介绍了完整日历调度程序中的资源数组不在IE 11中填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用完整的日历调度程序(1.6.2),我正在从一些下拉菜单中检索资源,并创建数组并提供完整的日历调度程序。资源已成功添加到Firefox中,但在IE 11中只添加了最后一次选择的下拉列表,下面是我的代码。我缺少什么或在完整日历中是否有任何错误。



<$每一个(函数(){
var id = $(this).attr('id'); $ b(pre $)$($'code> $(#schedule_employees> option:selected $ b var title = $(this).text();
item = {}
item.id = id;
item.title = title;
employees.push( item);
employee2 = employee2 + $(this).attr('id')+,;
});

if(employees.length == 0){
alert(请选择员工);
返回false;
}

$('#calendar')。fullCalendar('destroy');
$('#calendar')。fullCalendar({
aspectRatio:'1',
height:auto,
scrollTime:'00:00',
标题:{
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:'议程2天',
持续时间:{
天:2
},
},
计划:{
类型:'时间表',
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%',
资源:employees,
viewRender:function(view,element){
renderScheduleReport(employee2);
},
eventClick:function(event,jsEvent,view){
alert(hi);
}
});


解决方案

经过几个小时的调试,我发现发生了什么问题。在下面的循环中,employees数组为每次迭代都包含相同的元素,替换现有的元素,因此最终变量中包含相同的元素。不知道为什么IE总是会造成麻烦。

  $(#schedule_employees> option:selected)。each(function(){
var id = $(this).attr('id');
var title = $(this).text();



  item.id = id; 
item.title = title;
employees.push(item);
employee2 = employee2 + $(this).attr('id')+ ,;
});


I am using full calendar scheduler (1.6.2) and i am retrieving the resources from some drop down and creating the array and feed to full calendar scheduler. Resources are successfully added in firefox but in IE 11 only the last selected dropdown is added,below is my code.what am i missing or is there any bug in full calendar.

$("#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");
    }
});
解决方案

after hours of debugging i have found what's going wrong.In the below loop employees array contains the same element for each iteration ,replacing the existing one so in the end variable contains the same elements.Don't know why IE always causing trouble.

$("#schedule_employees > option:selected").each(function() {
    var id = $(this).attr('id');
    var title = $(this).text();

change the below line from

to

    item.id = id;
    item.title = title;
    employees.push(item);
    employee2 = employee2 + $(this).attr('id') + ",";
});

这篇关于完整日历调度程序中的资源数组不在IE 11中填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 12:18