How I handle KendoWindow Yes-No click function

3 posts, 0 answers
  1. Pierre
    Pierre avatar
    261 posts
    Member since:
    Apr 2007

    Posted 24 Oct 2018 Link to this post

    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
         wndDiv.find("#yes").click(function (e) {
                // Hit YES
                kendo.ui.progress($("#gridTest"), true);
                    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") {
                            kendo.ui.progress($("#gridTest"), false);
                        } else {
                            alert("Error occurs on the Database level!");
                    error: function () {
                        alert("An error has occured!!!");
        wndDiv.find("#no").click(function (e) {
                    //Hit NO


    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.

  2. Pierre
    Pierre avatar
    261 posts
    Member since:
    Apr 2007

    Posted 24 Oct 2018 in reply to Pierre Link to this post

    For now I add this function that I call from my Ajax Callback function or when the user click "NO" on the model windows. 

    function CleanModal(domId) {
        var wndDiv = $(domId);

    In this way I remove the click function on the YES and NO button so when I reopen the modal windows, I do not double the click event and that stop calling the Ajax 2X instead of one.

    But I don't know if this is clean enough?

  3. Ianko
    Ianko avatar
    1945 posts

    Posted 26 Oct 2018 Link to this post

    Hi Pierre,

    There is a predefined confirm Dialog widget that does exactly what it is required: You can check the API reference too:
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top