Kendo上传 - 如何为文件删除按钮单击添加javascript事件处理程序

时间:2016-01-07 07:38:31

标签: kendo-ui synchronous kendo-upload

我的剑道模板如下:

<div id="file-err-msg" > Please remove files with errors</div>
<input name="files" id="files" type="file" />
<script id="fileTemplate" type="text/x-kendo-template">
    <span class='k-progress'>
    </span>
    <strong class='k-upload-status'>
        <button type='button' class='btn-remove k-button k-button-bare k-upload-action'> 
            <span class='k-icon k-i-close k-delete' title='Remove'></span>
        </button>
    </strong>
</script>
<script>
    $("#files").kendoUpload({
        template: kendo.template($('#fileTemplate').html())
    });
</script>

当点击删除按钮时,我需要使用id - file-err-msg隐藏div。单击带有css类“k-delete”的跨度时,将执行“删除”操作。我需要另外添加下面的事件处理程序,它永远不会被调用。

$(".k-delete").click(function () {
    alert("Remove button clicked");
});

因为这些控件是动态呈现的,所以我尝试将它们绑定到事件处理程序,如下所示,但没有任何效果。

$("body").on("click", ".btn-remove", function () {
    alert("dynamic control event handler");
});

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

根据Kendo Upload API documentation,您可以将函数绑定到remove事件。 因此,您可以隐藏file-err-msg div:

$("#files").kendoUpload({
    template: kendo.template($('#fileTemplate').html()),
    remove: function(e) {
        $('#file-err-msg').hide();
    }
});
相关问题