Has anyone figured out how to add icons to the buttons in a bootbox.js dialog? I'd like to add icons to the "No" and "Yes" buttons in this function:
$(function () {
$(".confirm-delete").click(function(e) {
e.preventDefault();
var id = $(this).data('id')
bootbox.confirm("Remove this product?", "No", "Yes", function(confirmed) {
if(confirmed) {
deleteRecord(id);
}
});
});
});
You need to create a custom dialog and use the icon configuration option added in 2.1.0.
For example:
$(function () {
$(".confirm-delete").click(function(e) {
e.preventDefault();
var id = $(this).data('id')
bootbox.dialog("Remove this product?", [{
"label" : "No",
"icon" : "icon-remove"
}, {
"label" : "Yes",
"icon" : "icon-ok icon-white",
"callback": function() {
deleteRecord(id);
}
}]);
});
});
Custom dialog example
bootbox.confirm({
title: "Destroy planet?",
message: "Do you want to activate the Deathstar now? This cannot be undone.",
buttons: {
cancel: {
label: '<i class="fa fa-times"></i> Cancel'
},
confirm: {
label: '<i class="fa fa-check"></i> Confirm'
}
},
callback: function (result) {
console.log('This was logged in the callback: ' + result);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With