【问题标题】:Kendo upload - how to add a javascript event handler for file remove button click剑道上传 - 如何为文件删除按钮单击添加 javascript 事件处理程序
【发布时间】:2016-01-07 07:38:31
【问题描述】:

我的剑道模板如下:

<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");
});

感谢任何帮助!

【问题讨论】:

    标签: kendo-ui synchronous kendo-upload


    【解决方案1】:

    根据Kendo Upload API documentation,您可以将函数绑定到remove 事件。 所以这是你可以隐藏你的file-err-msg div 的地方:

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

    【讨论】:

    • 我相信删除事件只有在上传小部件是异步的情况下才有效。
    猜你喜欢
    • 2011-10-13
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多