I'm struggling to figure out how to make drag and drop functionality work. The getData/setData methods are puzzling me.
Here's the code I'm working with: http://jsfiddle.net/ASKte/218/
var el = angular.element(document.getElementById('drag'));
el.attr("draggable", "true");
el.bind("dragstart", function(e) {
e.dataTransfer.setData('text', 'Why won't you show up?!')
});
var target = angular.element(document.getElementById('drop'));
target.bind("dragover", function(e) {
if (e.preventDefault) {
e.preventDefault(); // Required for dropping items.
}
return false;
});
target.bind("dragenter", function(e) {
console.debug(e.dataTransfer.types);
console.debug(e.dataTransfer.getData('text'));
});
I chose to use AngularJS in this case, as it's part of a larger project.
Whenever I drag the top square onto the bottom one, the value retrieved by getData('text') is always blank. I'm baffled by this issue...
Any insights or suggestions would be greatly appreciated!
Thank you in advance.