Shaheed Haque
Shaheed Haque

Reputation: 723

Why is jquery-ui droppable with "accept" option as a function is ignored

I am using jQueryUI 1.12.1 to try to make some <input type="file"> elements droppable. This works when no options are specified, but when I try to use the "accept" option, specified as a function, nothing happens:

$('input[type="file"]').droppable({
    tolerance: "touch",
    accept: function (draggable) {
        console.log("hi", draggable);
        return false;
    }
});

The droppable file input ALWAYS accepts the file, and the function is NEVER called (and the log message is never seen/no breakpoint in the function is hit).

Any suggestions as to what I am doing wrong are most welcome.

Upvotes: 0

Views: 28

Answers (1)

Shaheed Haque
Shaheed Haque

Reputation: 723

As @Barmar points out, browsers have native support for dropping things on file inputs, so while the call to .droppable() does things like add the CSS classes jQueryUI documents to the file inputs involved, the accept attribute does not work.

(Perhaps the browser's support is not compatible with the logic that jQueryUI normally applies to droppables; this likely applies in other regards too).

Upvotes: 0

Related Questions