Drag and drop file upload reset

web
mobile

Topic: Drag and drop file upload reset

LTMG01 pro premium asked 9 months ago

I have a form that contains the option for users to select one of the following: "upload a file now" or "email a file later".

If the user selects the "upload a file now" option then a part of the form slides down that contains the MDB drag and drop file upload. If the user selects "email a file later" then this part of the form stays hidden.

My question/scenario is as follows: if the user first chooses to upload a file and adds that file through the drag and drop functionality, is there a way to reset the drag and drop field if that user then changes his mind and chooses to select "email a file later"? In other words, I would need to fire the same event(s) that are fired when the REMOVE button is clicked after a file was selected without actually clicking that REMOVE button. What would that/those event(s) be?


Anna Morawska staff answered 9 months ago

Hi there,

you can simulate a click event like this:

document.getElementsByClassName('btn btn-sm btn-danger')[0].click()

Best,

Ania


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: jQuery
  • MDB Version: 4.6.1
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: No