Hi, I am new with KendoWindow and I got some destroys problem. I use Model KendoWindow to ask confirmation of action on a KendoGrid function. For example, ask for deletion of an item or ask for some item action.
So an button on the command column call a function that ask with modal KendoWindow something than do an AjaxCall to the controller, then reload the grid.
function CalledByTheGridCommandButton() { var wndDiv = $("#CopyModalWindows"); var wnd = wndDiv.kendoWindow({ title: "Report copy", modal: true, visible: false, resizable: false, width: 350 }).data("kendoWindow"); wndDiv.find("#yes").click(function (e) { // Hit YES e.preventDefault(); wnd.close(); kendo.ui.progress($("#gridTest"), true); $.ajax({ url: "/Admin/Inv_Copy", type: "POST", data: JSON.stringify({ 'SourceId': selectedItem.FicheInventaireId, 'Annee': $("#AnneeInput").val(), 'Createur': $("#CreateurInput").val() }), dataType: "json", traditional: true, contentType: "application/json; charset=utf-8", success: function (data) { if (data.status === "Success") { //Success kendo.ui.progress($("#gridTest"), false); kendoGrid.dataSource.read(); } else { alert("Error occurs on the Database level!"); } }, error: function () { alert("An error has occured!!!"); } }); }); wndDiv.find("#no").click(function (e) { //Hit NO e.preventDefault(); wnd.close(); });}
But How I can destroy the windows and remove the event on YES and NO button? Do I do it correctly because if I hit several times the command button of the grid I will get multiple YES event attach, then called with unexpected result.
Thanks for your help.
