I would like to use jQuery’s UI dialog box for confirmation:
$( "#dialog-confirm" ).dialog({
buttons: {
"Button One": function() {
$( this ).dialog( "close" );
},
"Button Two": function() {
$( this ).dialog( "close" );
}
}
});
});
But I would like to change the button labels based on condition:
if (status == "active") {
var b1 = "Red";
var b2 = "Green";
} else {
var b1 = "Green";
var b2 = "Red";
}
Can’t seem to be able to combine the two…
You can set the buttons after the jQuery UI Dialog after it has been created, by supplying a new buttons array.
If you change the
statusvariable to anything apart fromactivein this demo you can see the buttons get created with different labels.