Relative Content

Tag Archive for javascripthtmldrag-and-drop

Is it possible to use the HTML5 Drag and drop API with JSON and JavaScript?

If I use static images in an HTML, the Drag n drop API works, but I need to add properties to the images to manipulate those properties later with JS (the images are about games and I wanna add price, id, name, etc.) so I made a JSON containing the images and properties. I fetch that JSON and get the images I’m gonna drag in a div with JS. When it comes to the ‘dragstart’ event it doesn’t work and I don’t get any errors when I start dragging an image. The images are there but it’s like Chrome or even Firefox doesn’t read them. Here’s my JS:

HTML drag and drop, empty file list

I have implemented HTML drag and drop, but facing an issue. When trying to drop images from my file system (operating system), the drop event sometimes returns the dropped files, while sometimes it just return empty file list. Its just a random occurrence, any help will be appreciable.