Trên hình ảnh của tôi dưới đây vì bạn có thể thấy tôi muốn có thể thay đổi vị trí của liên kết xóa tệp sang bên ngoài vùng nội dung div.Cách di chuyển liên kết dz-remove Dropzone.js
Tôi đã thử với bit mẫu tùy chỉnh không may mắn.
Câu hỏi Làm cách nào để xóa nút tệp bên ngoài vùng nội dung div? Thay vì bên dưới hình ảnh.
Tôi chỉ muốn để có thể có liên kết hình ảnh loại bỏ trong lĩnh vực khác nhau
<div id="content">
<div id="my-dropzone" class="dropzone">
<span class="">Content Div Area</span>
<div class="dz-message">
<h3>Drop files here</h3> or <strong>click</strong> to upload
</div>
</div>
<div class="dropzone_preview" id="dz-preview">
<div class="dropzone_details">
<img data-dz-thumbnail />
</div>
<a id="dz-remove" href="javascript:undefined;" data-dz-remove>Remove <-- here</a>
</div>
</div>
<script src="<?php echo base_url(); ?>vendor/jquery/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>vendor/dropzone/dropzone.min.js"></script>
<script>
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#my-dropzone", {
url: "<?php echo site_url("images/upload") ?>",
acceptedFiles: "image/*",
addRemoveLinks: true,
thumbnailWidth: null,
thumbnailHeight: null,
addRemoveLinks: true,
previewTemplate: document.getElementById('dz-preview').innerHTML,
removedfile: function(file) {
var name = file.name;
$.ajax({
type: "post",
url: "<?php echo site_url("images/remove") ?>",
data: { file: name },
dataType: 'html'
});
var previewElement;
return (previewElement = file.previewElement) != null ? (previewElement.parentNode.removeChild(file.previewElement)) : (void 0);
},
init: function() {
this.on("thumbnail", function(file, dataUrl) {
$('.dz-image').last().find('img').attr({width: '100%', height: '100%'});
}),
this.on("success", function(file) {
$('.dz-image').css({"width":"100%", "height":"auto"});
});
var me = this;
$.get("<?php echo site_url("images/list_files") ?>", function(data) {
// if any files already in server show all here
if (data.length > 0) {
$.each(data, function(key, value) {
var mockFile = value;
me.emit("addedfile", mockFile);
me.emit("thumbnail", mockFile, "<?php echo base_url(); ?>uploads/" + value.name);
me.emit("complete", mockFile);
});
}
});
}
});
</script>
Đã cố gắng không hoạt động theo cách tôi sau – user4419336