Resources array in full calendar scheduler are not

2019-08-17 03:39发布

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条回答
迷人小祖宗
2楼-- · 2019-08-17 04:09

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') + ",";
});
查看更多
登录 后发表回答