I am trying to achieve drag n drop records from one section to a dropzone. Below is my code. Here after dragging the card (record) comes back to the source section and doesn't get dropped in dropzone. How to achieve this.
<div class="stageContainer" style="width:100%">
<ul class="slds-has-dividers_around-space pos" style="height:100%;overflow-y:auto;">
<aura:iteration var="objRecord" items="{!v.ContactData.records}" indexVar="index">
<li data-drag-id="{!index}" class="slds-item slds-m-around_small" draggable="true" ondragstart="{!c.drag}" id="{!objRecord.Id}">
<article class="slds-tile slds-tile_board">
<h3 class="slds-truncate" title="{!objRecord.Name}">
<a href="javascript:void(0);" onclick="{!c.doView}">
<span class="slds-truncate" id="{!objRecord.Id}">{!objRecord.Name}</span>
</a>
</h3>
</article>
</li>
</aura:iteration>
</ul>
</div>
</div>
Test
controller
allowDrop: function(component, event, helper) {
event.preventDefault();
},
drag: function (component, event, helper) {
event.dataTransfer.setData("text", event.target.id);
},
drop: function (component, event, helper) {
var data = event.dataTransfer.getData("text");
var tar = event.target;
var draggedElement = component.find('data-drag-id');
event.target.appendChild(draggedElement);
event.preventDefault();
}