javascript确认框在kendo Grid Edit按钮上多次触发

时间:2019-05-12 09:23:57

标签: kendo-ui

我有一个确认对话框,它会在剑道网格编辑按钮上触发,当我单击编辑按钮时,确认框会多次触发。请帮忙!

function deleteDocument(currentRow)
{
currentRow.preventDefault();

var documentGridsRow=$("#documentKendoGrid").data("kendoGrid");
var gridDocument= 
documentGridsRow.dataItem($(currentRow.target).closest("tr"));

var fileUrl="xyz";

var r = confirm("Do you want to delete this file!");

if (r == true) 
    {
        var requestURI=_spPageContextInfo.webAbsoluteUrl + "/_api/web/getfilebyserverrelativeurl('" + fileUrl + "')";

    $(".loading1").show();
    $.ajax(
    {
        "url": requestURI,
        "method": "POST",
        "headers": 
        {
            "accept": "application/json;odata=verbose",
            "content-type": "application/json;odata=verbose",
            "X-HTTP-Method": "DELETE",
            "If-Match": "*",
            "X-RequestDigest": formDigestElement.value
        },
        async:false,
        success: function (data) 
        {
            kendo.alert("File Deleted Successfully!");
            var grid = $("#documentKendoGrid").data("kendoGrid");
            grid.destroy();
            displayAllDCRequirmentDocument($("#dcCycleFilter :selected").text());
            $('#documentKendoGrid').data('kendoGrid').refresh();
            $(".loading1").hide();

        },
        error: function (error) {
            kendo.alert("Fail!");
            $(".loading1").hide();
        }
    });
} 
else
{
        console.log("Delete File Fail!");   
}

}

0 个答案:

没有答案