From 67de50d2e13c603d77e79cc3001e7c049de61792 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Sat, 10 Mar 2018 12:54:08 +0100 Subject: [PATCH] Add event listeners in favor of overloading attributes Overloading the onsubmit or onclick attribute and collide with other libraries that might do the same mistake. In this case the last executed script would overwrite the privious listener. --- s3file/static/s3file/js/s3file.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s3file/static/s3file/js/s3file.js b/s3file/static/s3file/js/s3file.js index 72720b4..ba0bd95 100644 --- a/s3file/static/s3file/js/s3file.js +++ b/s3file/static/s3file/js/s3file.js @@ -106,13 +106,13 @@ }) forms = new Set(forms) forms.forEach(form => { - form.onsubmit = (e) => { + form.addEventListener('submit', (e) => { e.preventDefault() uploadS3Inputs(e.target) - } + }) let submitButtons = form.querySelectorAll('input[type=submit], button[type=submit]') Array.from(submitButtons).forEach(submitButton => { - submitButton.onclick = clickSubmit + submitButton.addEventListener('click', clickSubmit) } ) })