How to disable OK button of modal dialog in jQuery

I want to disable the OK button of a modal dialog after clicking OK in jQuery.

+3
source share
2 answers

Record the disable action in your Ok button click event, following

"Ok": {                          
       click: function () {
          $(".ui-dialog-buttonpane button:contains('Ok')")
                          .attr("disabled", true)
                          .addClass("ui-state-disabled");
                        }
      }

All the buttons in your dialog box will be entered above the code and select the "OK" button, and adding an attribute is disabled only for this button.

+2
source
"Ok": {
    click: function (e) {
        $(e.target)
            .attr("disabled","disabled")
            .addClass("ui-state-disabled");
        return false;
    }
}

or if localized:

buttons = {};
buttons[strings.buttons.ok] = function(e){
    $(e.target)
        .attr("disabled","disabled")
        .addClass("ui-state-disabled");
    return false;
}
0
source

Source: https://habr.com/ru/post/1736666/


All Articles