[英]Preprocess before kendo ui upload
我想將一些數據(GUID)傳遞給kendoUpload的上載方法,以便特定的MVC Controller操作方法將接收該數據。 每次上傳時,我都需要傳遞此數據(引導)。
$("#propertyAttachmentUpload").kendoUpload({
async: {
saveUrl: fileUploadUrl,
chunkSize: 1048576,
removeUrl: "remove"
},
multiple: true,
upload: function (e) {
e.data = { id: $("#fileUplpderParentObjectId").val(), fileId: fileId };
},
showFileList: false,
dropZone: ".propertyAttachmentDropZone",
success: onSuccess
});
字段是fileId
。 我可以在上載按鈕的click事件中調用上面的代碼塊,它可以工作,但是Kendo UI樣式在初始化時未應用於上載按鈕。
$("#propertyAttachmentUpload").click(
function() {
var fileId = guid();
$("#propertyAttachmentUpload").kendoUpload({
async: {
saveUrl: fileUploadUrl,
chunkSize: 1048576,
removeUrl: "remove"
},
multiple: true,
upload: function (e) {
e.data = { id: $("#fileUplpderParentObjectId").val(), fileId: fileId };
},
showFileList: false,
dropZone: ".propertyAttachmentDropZone",
success: onSuccess
});
});
如何在不失去Kendo UI樣式的情況下初始化fileId。
注意:我無法在upload
方法內調用guid()
因為上載方法會為每個上載塊調用。 對於所有塊,特定文件的fileId應該相同。
我已經使用全局變量並在上傳按鈕的click事件中設置了該變量,從而解決了該問題,
var fileGuid = '';
$(document).on('click', '#propertyAttachmentUpload', function() {
fileGuid = "";
fileGuid = guid();
})
$("#propertyAttachmentUpload").kendoUpload({
async: {
saveUrl: fileUploadUrl,
chunkSize: 1048576,
removeUrl: "remove"
},
multiple: true,
upload: function (e) {
e.data = { id: $("#fileUplpderParentObjectId").val(), fileId: fileGuid };
},
showFileList: false,
dropZone: ".propertyAttachmentDropZone",
success: onSuccess
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.