首先,我想说我的英语不好,所以我想道歉。我的问题是我试图自定义 FineUploader FileTemplate 选项但没有成功。我不想使用fineUploaderBasic。我想要完全定制。首先,我试图在上传成功后隐藏文件名和大小并且我成功地做到了,但是当我尝试自定义删除按钮时,问题就开始了。上传后删除按钮出现但禁用,我无法单击它。下面是我的代码:
var restricteduploader = new qq.FineUploader({
element: $('#restricted-fine-uploader')[0],
text: {
uploadButton: '<div><i class="icon-upload icon-white"></i>Subir Imagen</div>',
deleteButton: '<input type="button" id="btnDelete" value="Eliminar imagen" />'
},
template:
'<div class="qq-uploader">' +
'<div class="qq-upload-drop-area"><span>{dragZoneText}</span></div>' +
'<div class="qq-upload-button">{uploadButtonText}</div>' +
'<span class="qq-drop-processing"><span>{dropProcessingText}</span><span class="qq-drop-processing-spinner"></span></span>' +
'<ul class="qq-upload-list"></ul>' +
'</div>',
fileTemplate:
'<li>' +
'<div class="qq-progress-bar"></div>' +
'<span class="qq-upload-spinner"></span>' +
'<span class="qq-upload-finished"></span>' +
'<span class="qq-edit-filename-icon"></span>' +
'<span class="hide-file"></span>' +
'<div>IMAGEN SUBIDA CON EXITO!!</div>' +
'<input class="qq-edit-filename" tabindex="0" type="text">' +
'<span class="hide-size"></span>' +
'<a class="qq-upload-cancel" href="#">{cancelButtonText}</a>' +
'<a class="qq-upload-retry" href="#">{retryButtonText}</a>' +
'<div class="qq-upload-delete">{deleteButtonText}</div>' +
'<span class="qq-upload-status-text">{statusText}</span>' +
'</li>',
classes: {
file: 'hide-file',
size: 'hide-size'
},
request: {
endpoint: '<%= Url.Action("UploadBatchDataFile", "Account") %>'
},
deleteFile: {
enabled: true,
endpoint: '<%= Url.Action("DeleteFile", "Account") %>',
method: 'POST'
},
multiple: false,
validation: {
allowedExtensions: ['jpeg', 'jpg', 'png'],
sizeLimit: 411062 // 50 kB = 50 * 1024 bytes
},
showMessage: function (message) {
$('#restricted-fine-uploader').append('<div class="alert-error">' + message + '</div>');
},
//listElement: document.getElementById('files'),
messages: { typeError : "{file} no es un tipo de imagen valido. Imagenes valida(s): {extensions}." },
callbacks: {
onSubmitDelete: function(event, id) {
var filename = $(this).fineUploader('getName', id);
$(this).fineUploader('setDeleteFileParams', {filename: filename}, id);
},
onComplete: function (id, filename, responseJSON) {
if (responseJSON.success) {
$('div div.alert-error').remove();
$('#imgUploaded').attr("src", "<%: Url.Content("~/Images/") %>" + responseJSON.filename);
$('#hidImage').attr("value", "<%: Url.Content("~/Images/") %>" + responseJSON.filename);
}
}
}
});
对我来说,自定义 fileTemplate 非常困难,在此之前我试图使 FileTemplate 成为表格的一部分,在模板上更改它
'<ul class="qq-upload-list"></ul>' to '<table class="qq-upload-list"></table>'
这在文件模板上
'<li>' to '<tr><td>' and '</li>' to </td></tr>
但这又不起作用,在成功上传 FineUploader 后没有向我显示 FileTemplate。