Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icons for bootbox js dialogs

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);
            }
        });
    });     
});
like image 398
skyetech Avatar asked Dec 07 '25 08:12

skyetech


2 Answers

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

like image 108
Sara Avatar answered Dec 09 '25 00:12

Sara


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);
    }
});
like image 22
Michael Oxborrow Avatar answered Dec 09 '25 01:12

Michael Oxborrow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!