Joseph Michael Pesch
VP Programming

jQuery Dialog Disable Ok Button

by 24. June 2013 13:43

In some cases depending on the usage you may have a jQuery dialog open after the user clicks the Ok button; however, you may want to disable the button to prevent the user from double-clicking it.  Here are a couple of methods to achive this typ of behavior.  

Just disable the Ok button:

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

Remove all buttons and replace with a processing indicator:

     title: 'Sample Dialog', 
     modal: true, 
     buttons: { 
       'Cancel': function() { $(this).dialog('close'); },
       'Ok': function() { $('.ui-dialog-buttonpane').html('<div style="width: 100%; text-align: center; padding: 20px; font-size: 20px; background: url(processing.gif) no-repeat;">Processing please wait...</div>'); 



Comments are closed