-
Notifications
You must be signed in to change notification settings - Fork 0
/
customize_dropzonejs.js
64 lines (55 loc) · 2.02 KB
/
customize_dropzonejs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* https://stackoverflow.com/questions/23716048/non-ajax-post-using-dropzone-js */
Dropzone.autoDiscover = false;
jQuery(document).ready(function () {
//jQuery("#commentform").attr("enctype","multipart/form-data");
Dropzone.autoDiscover = false;
jQuery("#media-uploader").dropzone({
url: 'someurl',
autoProcessQueue: false,
addRemoveLinks: true,
paramName: 'testfile',
init: function() {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
// for Dropzone to process the queue (instead of default form behavior):
document.getElementById("submit").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
dzClosure.processQueue();
});
this.on("success", function (file, response) {
$('#hidden_image_name').val(response);
});
}
});
});
/*
Dropzone.autoDiscover = false;
jQuery("#media-uploader").dropzone({
url: dropParam.upload,
acceptedFiles: 'image/*',
success: function (file, response) {
file.previewElement.classList.add("dz-success");
file['attachment_id'] = response; // push the id for future reference
var ids = jQuery('#media-ids').val() + ',' + response;
jQuery('#media-ids').val(ids);
},
error: function (file, response) {
file.previewElement.classList.add("dz-error");
},
// update the following section is for removing image from library
addRemoveLinks: true,
removedfile: function(file) {
var attachment_id = file.attachment_id;
jQuery.ajax({
type: 'POST',
url: dropParam.delete,
data: {
media_id : attachment_id
}
});
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
*/