$(this) 无法处理 Kendo 文件上传

$(this) not working on Kendo file upload

我的 kendo 网格中有 kendo 上传控件作为列之一。请在下面的栏中找到:

$(".files").kendoUpload({
    async: {
        saveUrl: "/api/test/test/test",
        removeUrl: "/api/test/test/test",
        autoUpload: true
    },
    success: onSuccess,
             multiple:false,
             error: onError,
             showFileList: true,
             validation: {
                 allowedExtensions: [".pdf", ".xlsx", ".docx", ".rtf", ".tif",".txt"],MaxFileSize:5242880
             }
});

行模板:

 template: '<div class="small-12 attachment-wrapper columns"><div class="row"><div class="small-11 columns"><textarea placeholder="Enter notes and descriptions here for claims that have been closed"></textarea></div></div><div class="row"><div class="small-6 attachment columns"><div class="demo-section k-content"><input name="files" class="files" id="files" type="file" /><span class=success></span></div></div></div>'

我正在尝试使用成功上传文件获得的结果来更新最近的跨度。

function onSuccess(e) {
    alert(e.response.FileName);

    $(this).closest('span .success').text(e.response.FileName);
}

但我找不到跨度,它总是说未定义。我认为 $(this) 不适用于 kendo controls 。 当我对按钮执行相同的操作时,它确实有效。如何使用 jquery .

获取上传控件的上下文和最近的跨度

请对此提出建议

在这种情况下,"this" 不是对上传小部件的 DOM 元素的引用,它是对上传 widget/class 本身的引用。

尝试

this.wrapper.closest(...)

相反。

我从对方那里找到了答案post :

Check here

this.element.context.closest('td') 

然后我们可以获得对列的 jquery 对象的引用,我们可以从中轻松找到跨度。

希望这对其他人有所帮助