我尝试在我的联系表上使用DropzoneJS库,我已经导入了js dropzone文件,但仍然无法正常工作...我已经用Google搜索,但每个帖子都是针对php而不是WP Contact表单>
我试图将其添加到我的联系表中:
<div class="row">
<div class="col-md-12">
<div id="media-uploader" class="dropzone"></div>
<input type="hidden" name="media-ids" value="">
[file file1]</label>
</div>
</div>
并使用它来使它起作用,但不能:
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;
}
});
我当然使用以下命令导入了js / css文件:wp_enqueue_script