2

A screenshot of my interface:

enter image description here

Each element of the tree is a <li> and a <a>.

Each folder is a dropzone for file-upload like the gmail upload drag-and-drop.

When I "drag enter" on a folder with a file from my machine, I add a style:

enter image description here

The code for this:

var dropZoneElement = document.getElementById($this.attr('id'));

dropZoneElement.addEventListener('dragenter', onDragEnter, false);
dropZoneElement.addEventListener('dragleave', onDragLeave, false);
dropZoneElement.addEventListener('drop', onDrop, false);

function onDragEnter(event) {
  event.preventDefault();
  event.stopPropagation();
  $this.addClass('gmail-like');
}

function onDragLeave(event) {...}
function onDrop(event) {...}

But the problem is that when I drag a link (<a>) on a folder (even the fake link test with no destination, see screenshot), the page add the style to upload (no upload, it's just visual):

enter image description here

  • Why?
  • Any idea to disable this?

I would like the style applies only when I drag-and-drop a file from my machine.

1 Answer 1

2

Basically, you need to check the drag data item kind and verify that is indeed a file and not something else. Also, you can disable the

Have a look at the HTML5 draft describing the drag&drop process. This tutorial may also provide some help.

Finally, the following SO question should give you some concrete hints.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.