Personal I need an Alert with the "Confirm" button instead of the "OK" button. How do I do this?
Personal I need an Alert with the "Confirm" button instead of the "OK" button. How do I do this?
One option is to use some plugin that will mount a custom confirmation window. The advantage is that you can style with the colors and text you want. The downside is having to use one more plugin in your code.
For example, see the Dialog functionality of jQuery UI:
Considering that jQuery UI is installed, the code looks like this:
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Remover todos os itens?": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Todos os itens serão removidos. Deseja continuar?</p>
</div>
PS: If you want something more "modern", this option is legal too:
Instead of alert
use the confirm
function, it returns true
if the user confirms the action, however the button text of both functions can not be changed, it is relative to the browser used.
Another possible solution would be to create a custom alert with Javascript and CSS.