0

I have one droppable area that contains a list of Field Names (all individually draggable), and then a table with X headers that are all droppable and initially empty.

Is there a way to tell when an item has been removed from a table header? I'm thinking of if a user drops a header from one TH to another TH or if a user drags a field from a TH back to fieldNamesDroppable. Then I would have updated two columns or one outdated column.

Current code:

$('#fieldNamesDroppable').droppable({
    drop: function (event, ui) {
        ui.draggable.appendTo($(this)).css({
            top: '0px',
            left: '0px'
        });
    }
});

$('th').droppable({
    drop: function (event, ui) {
        var $this = $(this);

        // if there is already an item here, cancel the drop and flash error message
        if ($this.find('.drag').length >= 1) {
            ui.draggable.draggable('option', 'revert', true);
            errorMessage("You can only add one heading to each column.");
            return;
        }

        // else, drop item
        $this.html('');
        ui.draggable.appendTo($this).css({
            top: '0px',
            left: '0px'
        });

        // update the field mappings in the controller
        updateFieldMappingsInput(ui.draggable);
    }
});

Where 'updateFieldMappingsInput' updates a related process for keeping track of the headers mappings.

4

1 回答 1

1

我相信你想要的是out事件,它在 API 中被描述为:

当接受的可拖动对象被拖出可放置对象时触发(基于容差选项)。

于 2013-09-11T20:17:48.480 回答