If you're including the .button()
plugin/widget that jQuery UI contains (if you have the full library and are on 1.8+, you have it), you can use it to disable the button and update the state visually, like this:
$(".ui-dialog-buttonpane button:contains('Confirm')").button("disable");
You can give it a try here...or if you're on an older version or not using the button widget, you can disable it like this:
$(".ui-dialog-buttonpane button:contains('Confirm')").attr("disabled", true)
.addClass("ui-state-disabled");
If you want it inside a specific dialog, say by ID, then do this:
$("#dialogID").next(".ui-dialog-buttonpane button:contains('Confirm')")
.attr("disabled", true);
In other cases where :contains()
might give false positives then you can use .filter()
like this, but it's overkill here since you know your two buttons. If that is the case in other situations, it'd look like this:
$("#dialogID").next(".ui-dialog-buttonpane button").filter(function() {
return $(this).text() == "Confirm";
}).attr("disabled", true);
This would prevent :contains()
from matching a substring of something else.
.button()
plugin, so they're not necessarily the best/cleanest solutions anymore. – Mckim