fullcalendar事件拖放不能在Firefox中工作

时间:2015-09-17 15:07:00

标签: javascript html firefox drag-and-drop fullcalendar

拖放在其他浏览器上运行正常只有firefox有问题。

我已经阅读了足够的知识,Firefox有一种不同的拖放机制,但我找不到任何帮助 尝试实施jsEvent.preventDefault();作为评论员建议here 但这没有改变行为,我不知道如何实现标记为答案的部分event.originalEvent.dataTransfer.setData('text/plain', 'anything');

这是我的拖放代码:

设置draggable tr

$('#workOrdersTable tbody tr').each(function() {
    var tds = $(this).children('td');
    if (tds.length > 0) {
        var workOrder = $.grep(workOrders, function(e) {
            return e.woNumber == tds[0].innerText;
        })[0];
        if (typeof workOrder !== "undefined" || workOrder !== null) { // store the Event Object in the DOM element so we can get to it later
            $(this).data('workOrder', workOrder);
            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true, // will cause the event to go back to its
                revertDuration: 0 //  original position after the drag
            });
        }

    }
});

如何在Firefox中使用它?

FullCalendar设置实现drop

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    editable: false,
    droppable: true,

    //edit existing
    eventClick: function(calEvent, jsEvent, view) {
        populateEvent(calEvent, true);
    },

    //create new
    drop: function(date, jsEvent, ui ) {
        //alert('jsEvent '+jsEvent);
        jsEvent.preventDefault();

        var workOrder = $(this).data('workOrder');
        workOrder.title = workOrder.woNumber + ' ' + workOrder.account
        workOrder.description = workOrder.problemDescription;
        workOrder.start = date;
        workOrder.end = moment(date).add(1, 'hour'); //change default so the start and end dont match
        populateEvent(workOrder, false);
    },

1 个答案:

答案 0 :(得分:0)

问题在于将数据设置为可拖动行

var workOrder = $.grep(workOrders, function(e) {
        return e.woNumber == tds[0].innerText;
    })[0];

需要

        var woNumberTemp = tds[0].textContent || tds[0].innerText;
        var workOrder = $.grep(workOrders, function(e) {
            return e.woNumber == woNumberTemp;
        })[0];

显然,chrome tds[0].innerText很好,但firefox需要tds[0].textContent