Subversion Repositories Integrator Subversion

Rev

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
                init: function() {
10
                    this.on("addedfile", function(file) {
11
                        // Create the remove button
12
                        var removeButton = Dropzone.createElement("<button class='btn btn-sm btn-block'>Remove file</button>");
13
 
14
                        // Capture the Dropzone instance as closure.
15
                        var _this = this;
16
 
17
                        // Listen to the click event
18
                        removeButton.addEventListener("click", function(e) {
19
                          // Make sure the button click doesn't submit the form:
20
                          e.preventDefault();
21
                          e.stopPropagation();
22
 
23
                          // Remove the file preview.
24
                          _this.removeFile(file);
25
                          // If you want to the delete the file on the server as well,
26
                          // you can do the AJAX request here.
27
                        });
28
 
29
                        // Add the button to the file preview element.
30
                        file.previewElement.appendChild(removeButton);
31
                    });
32
                }            
33
            }
34
        }
35
    };
36
}();