Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
Submitting the form after dropzone.js uploads all images

I'm using dropzone.js as part of a form all working as it should. I have it set so it doesn't process the upload queue until submit is clicked. But once it's uploaded all files I want it to submit the form. I've added the event in jQuery but it's still not submitting it.

What am I doing wrong here?

It gave me the success alert but didn't submit the form:

$(document).ready(function() {
  
  $("div#dropzone").dropzone({ 
    url: "js/dropzone/upload.php",
    autoProcessQueue: false,
    maxFilesize: 2,
    parallelUploads: 100,
    uploadMultiple: true,
    acceptedFiles: "image/*",
    maxFiles: 10,
    init: function() {
      var myDropzone = this;
      $("#theform").submit(function(e) {
        e.preventDefault();
        e.stopPropagation();
        myDropzone.processQueue();
      });
    },
    completemultiple: function(file, response){
      alert("success");
      $("#theform").submit();
    },
  });
});
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You might set a flag if the form can be submitted, then decide if you need to preventDefault:

$(document).ready(function() {
  
  $("div#dropzone").dropzone({ 
    url: "js/dropzone/upload.php",
    autoProcessQueue: false,
    maxFilesize: 2,
    parallelUploads: 100,
    uploadMultiple: true,
    acceptedFiles: "image/*",
    maxFiles: 10,
    init: function() {
      var myDropzone = this;
      $("#theform").submit(function(e) {
        if ($(this).prop('ready')) return true;
        e.preventDefault();
        e.stopPropagation();
        myDropzone.processQueue();
      });
    },
    completemultiple: function(file, response){
      alert("success");
      $("#theform").prop('ready', true).submit();
    },
  });
});
about 4 years ago · Juan Pablo Isaza Report

0

I've managed to work it out. I'm sure other people will have the same problem so here is the answer. You reverse the e.preventDefault and then click the submit button with jQuery once the queue is complete:

$(document).ready(function() {

  $("div#dropzone").dropzone({ 
    url: "js/dropzone/upload.php",
    autoProcessQueue: false,
    maxFilesize: 2,
    parallelUploads: 100,
    uploadMultiple: true,
    acceptedFiles: "image/*",
    maxFiles: 10,
    init: function() {
      var myDropzone = this;
      $("#theform").submit(function(e) {
        e.preventDefault();
        e.stopPropagation();
        myDropzone.processQueue();

      });
    },
    queuecomplete: function(file, response){
      $("#theform").unbind('submit').submit();
      $("#submit").click();
    },
  });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!