I’m trying to implement some custom JS to allow for drag and drop files in a form and I’m wondering if anyone out there has some guidance. Right now I’m trying to use .addEventListener() to listen to dragover, dragleave, and similar. The function looks roughly like this:
function init() {
var filedrag = document.getElementsByClassName("anvil-role-drag");
filedrag.addEventListener("mouseenter", TestFunction);
}
But, when I run this function using .call_js(), I get the following error:
ExternalError: TypeError: filedrag.addEventListener is not a function Main, line 23
I can verify that filedrag does contain the appropriate number of items, so is .addEventListener() not an option at the moment? I have probably a grand total of four hours of JS experience, so the likelihood I’m making a mistake is high. All I can say is that I’m emulating existing JS code that works on another website. Thoughts?
