Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

353
Visualizações
How do I override the error function in dropzone.js?

The default error handler in dropzone.js is as follows and contains a default error implementation as below:

https://github.com/dropzone/dropzone/blob/main/src/options.js#L4

  // Called whenever an error occurs
  // Receives `file` and `message`
  error(file, message) {
    if (file.previewElement) {
      file.previewElement.classList.add("dz-error");
      if (typeof message !== "string" && message.error) {
        message = message.error;
      }
      for (let node of file.previewElement.querySelectorAll(
        "[data-dz-errormessage]"
      )) {
        node.textContent = message;
      }
    }
  },

Unfortunately the above code has the undesirable behaviour where if the server returns a non 2xx response, the HTML of that response is displayed as an error, which is incomprehensible to end users and makes them panic.

How do I replace the above callback in such a way that the above code is removed completely at runtime?

The following does not work, most specifically a breakpoint on the code above is still hit, and the HTML error text is still present:

  let dropzone = new Dropzone(document.body, { // Make the whole body a dropzone
    url: "/upload/url", // Set the url
    previewsContainer: "#previews", // Define the container to display the previews
    uploadMultiple: true,
    autoProcessQueue: true
  });
  dropzone.on("error", (file, response, xhr) => {
    console.log("An error has occurred: " + file + response + xhr.status + xhr.statusText);
  });
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda