Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var FormDropzone = function () { |
| 2 | |||
| 3 | |||
| 4 | return { |
||
| 5 | //main function to initiate the module |
||
| 6 | init: function () { |
||
| 7 | |||
| 8 | Dropzone.options.myDropzone = { |
||
| 9 | dictDefaultMessage: "", |
||
| 10 | init: function() { |
||
| 11 | this.on("addedfile", function(file) { |
||
| 12 | // Create the remove button |
||
| 13 | var removeButton = Dropzone.createElement("<a href='javascript:;'' class='btn red btn-sm btn-block'>Remove</a>"); |
||
| 14 | |||
| 15 | // Capture the Dropzone instance as closure. |
||
| 16 | var _this = this; |
||
| 17 | |||
| 18 | // Listen to the click event |
||
| 19 | removeButton.addEventListener("click", function(e) { |
||
| 20 | // Make sure the button click doesn't submit the form: |
||
| 21 | e.preventDefault(); |
||
| 22 | e.stopPropagation(); |
||
| 23 | |||
| 24 | // Remove the file preview. |
||
| 25 | _this.removeFile(file); |
||
| 26 | // If you want to the delete the file on the server as well, |
||
| 27 | // you can do the AJAX request here. |
||
| 28 | }); |
||
| 29 | |||
| 30 | // Add the button to the file preview element. |
||
| 31 | file.previewElement.appendChild(removeButton); |
||
| 32 | }); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | }; |
||
| 37 | }(); |
||
| 38 | |||
| 39 | jQuery(document).ready(function() { |
||
| 40 | FormDropzone.init(); |
||
| 41 | }); |