Resources array in full calendar scheduler are not populating in IE 11

有些话、适合烂在心里 提交于 2019-12-13 03:56:31

问题


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");
    }
});

回答1:


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

    item = {} //this is causing issue  

to

var item = {};

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


来源:https://stackoverflow.com/questions/45730849/resources-array-in-full-calendar-scheduler-are-not-populating-in-ie-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!