donmccurdy / simple-dropzone

A simple multi-file drag-and-drop input using vanilla JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing to use this in an app requiring es5 support

JxstWieslaw opened this issue · comments

How can l use this library in an app requiring es5 support only. I assumed that the .umd.js file would suffice. But l cannot create an instance of the namespace SimpleDropzone as it says "this is not a constructor"

Kindly assist on how l can resolve this (if possible) ?

If you console.log the SimpleDropzone object, it's a global wrapper around the package, with a class of the same name inside that. So usage would be:

<script src="https://unpkg.com/simple-dropzone@0.8.3/dist/simple-dropzone.umd.js"></script>
const dropzone = new SimpleDropzone.SimpleDropzone(el, input)

I can't guarantee that future versions will be ES5 – they might become ES6 or later, in the source code if not the module syntax. So I would consider copying this file into your codebase, or making sure to use a URL with a specific version number pinned.

Okay, thanks for the response.
Let me check this soon and revert. I have since used the esm cdn from jsdeliver.net : esm.run

I have since gotten some progress on it using type="module" on the script, but will need es5 code still. So will let you know.

I checked it out. I was able to access the element using this namespace you gave:
new SimpleDropzone.SimpleDropzone ( )

Thanks!