I am using the following to create a bootbox prompt message. (The title and the default value are obtained via an ajax request.)
bootbox.prompt({
title: response.message,
value: response.value,
buttons: {
confirm: {
label: 'Ok'
}
},
callback: function (result) {
}
});
Although i have setup only confirm
button, the prompt displays also the Cancel
Button.
What am i doing wrong here?
I have tried hiding the cancel button via css with no success like so
.btn btn-secondary btn-default bootbox-cancel{
visibility:hidden;
}
I really don't recommend doing this - standard user expectation for a prompt is to have an obvious way of cancelling it.
That being said... the d-none
class, when added to the Cancel button, will hide it:
bootbox.prompt({
title: 'Please enter something:',
callback: function(result){
console.log(result);
},
buttons: {
cancel: {
className: 'd-none'
}
}
});
Demo: https://jsfiddle.net/t3o5Lcnb/
You can't remove the Cancel or Confirm/OK buttons from the bootbox.alert
, bootbox.confirm
, or bootbox.prompt
dialogs, but you can customize them (change the text, add icons, set the button classes, or add custom classes). In this case, adding the d-none
Bootstrap class adds a display: none;
rule to the Cancel button.
You can find a few examples of customizing the buttons on the Examples page: http://bootboxjs.com/examples.html#confirm-alternate-text-color