I have confirm dialog box which trigger on kendo grid edit button, when i click on edit button confirm box fire multiple times. Please help!

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 Answers