3

I'm using dropzonejs. My HTML is as follows:

<div class="dropzone" id="upload1"></div> <script> $("#upload1").dropzone({ url: "upload.php?frm=logo", paramName: "post_ipfld", dictDefaultMessage: "Drop Files or Select", success: function(file, response) { $("#id").val($.trim(response)); ////////// Save the values in db $.ajax({ url: "save.php?frm=new", type: "post", data: $("#frm_save").serialize(), success: function(d) { $("#pid").val($.trim(d)); } }); } }); </script> 

The above is working fine. The problem is that I have a clear link in the end of the form. By clicking this clear link I need to clear some form fields but I can't get it to clear my dropzone field.

I am successfully clearing the form fields like this:

$('#fld1, #fld2, #fld5').val(''); 

To clear the dropzone I tried this:

var myDropzone = $("#upload1").dropzone(); myDropzone.removeAllFiles(true); $('div.dz-image').remove(); 

How do I use removeAllFiles()?

0

1 Answer 1

2

Here are two resources you should check out:

Basically, you need to add this init variable to your settings object and set a variable in the appropriate scope. It will create a function called clearDropzone which should do what you expect.

var clearDropzone; $("#upload1").dropzone({ init: function () { var dropzone = this; clearDropzone = function(){ dropzone.removeAllFiles(true); }; }, url: "save.php?frm=new", /* etc. */ } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.