Looks like anyone, even in this linked question, have proposed this solution, similar to the first part of the answer given by Nick Craver:
$("#dialog").dialog({
width: 480,
height: "auto",
buttons: [
{
id: "button-cancel",
text: "Cancel",
click: function() {
$(this).dialog("close");
}
},
{
id: "button-ok",
text: "Ok",
click: function() {
$(this).dialog("close");
}
}
]
});
Then, elsewhere, you should be able to use the API for the jquery UI button:
$("#button-ok").button("disable");