DropZonejs: Submit form without files

后端 未结 7 1774
一生所求
一生所求 2020-12-05 14:27

I\'ve successfully integrated dropzone.js inside an existing form. This form posts the attachments and other inputs like checkboxes, etc.

When I submit the form wit

7条回答
  •  心在旅途
    2020-12-05 14:59

    Pretty simple, you stop the propagation ONLY if you have files to be submitted via Dropzone:

    // First change the button to actually tell Dropzone to process the queue.
    this.element.querySelector("button[type=submit]").addEventListener("click", function(e) {
      // Stop the propagation ONLY if you have files to be submitted via Dropzone
      if (myDropzone.getQueuedFiles().length > 0) {
            e.preventDefault();
            e.stopPropagation();
            myDropzone.processQueue();
      }
    });
    

提交回复
热议问题