I would like to drag the divs of a sortable container and drop them on to a droppable div (which is not sortable). I have tried using html5 drag and drop events, but none of them are getting fired. Most importantly, dragstart event on sortable container is not getting fired. Can somebody suggest me a solution. I just want the dragstart event to be fired. Here is my complete code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Sortable - Handle empty divsts</title>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<style>
.draggableDivs{
background-color: orange;
border: solid black;
}
</style>
</head>
<body>
<div id="sortable" style="float: left;">
<div class="draggableDivs" draggable="true">Can be dropped !!..</div>
<div class="draggableDivs" draggable="true">..on an empty list</div>
<div class="draggableDivs" draggable="true">Item 3</div>
<div class="draggableDivs" draggable="true">Item 4</div>
<div class="draggableDivs" draggable="true">Item 5</div>
</div>
<div id="dropTarget" style="width: 500px; height: 500px; background-color: skyblue; float: left; text-align: center">
<h4>Drop Here</h4>
</div>
<script>
$("#sortable").sortable();
document.getElementById('sortable').addEventListener('dragstart', function(evt) {
console.log("The 'dragstart' event fired.");
evt.dataTransfer.setData('text', evt.target.textContent);
}, false);
</script>
</body>
</html>