如何解决jQuery删除文件后删除DropZone.js缩略图
我们在 DropZone.js
中有更多选项,例如 removedFile
。在此 Javascript 脚本中,我尝试在从服务器删除文件后删除 DropZone
缩略图。从服务器删除文件工作正常,但我无法分离缩略图
<script type="text/javascript">
var DropzoneUp = function () {
var _componentDropzone = function () {
if (typeof Dropzone == 'undefined') {
console.warn('Warning - dropzone.min.js is not loaded.');
return;
}
// Multiple files
Dropzone.options.dropzoneMultiple = {
paramName: "file",//...
params: {
prefixFile: '{{csrf_token()}}'
},removedfile: function (file) {
jQuery.ajax({
//...
dataType: "json",success: function (data) {
}
});
}
};
};
return {
init: function () {
_componentDropzone();
}
}
}();
DropzoneUp.init();
</script>
我该怎么做以及如何删除缩略图?
解决方法
我的问题在 success
回调函数中通过这段代码解决了:
removedfile: function (file) {
jQuery.ajax({
//...
type: "POST",dataType: "json",success: function (data) {
let _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
}
});
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。