I have a problem with my drag and drop item, when i drag got an error: "e.dataTransfer is undefined"
drag function
dragstart: function(e) {
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.dropEffect = 'move';
e.dataTransfer.setData('application/json', index);
element.addClass('dragging');
}
Someone know where is the problem?
The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. It may hold one or more data items, each of one or more data types. For more information about drag and drop, see HTML Drag and Drop API.
getData() The DataTransfer. getData() method retrieves drag data (as a string) for the specified type. If the drag operation does not include data, this method returns an empty string. Example data types are text/plain and text/uri-list .
Get the dragged data with the dataTransfer. getData() method. This method will return any data that was set to the same type in the setData() method. The dragged data is the id of the dragged element ("drag1")
Add dataTransfer
prop explicitly:
e.dataTransfer = e.originalEvent.dataTransfer;
In jquery you have to use it like this, it will work:
e.originalEvent.dataTransfer.dropEffect = 'move';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With