3

有没有人知道如何在 bootbox.js 对话框中的按钮上添加图标?我想在此功能的“否”和“是”按钮上添加图标:

$(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);
            }
        });
    });     
});
4

2 回答 2

4

您需要创建一个自定义对话框并使用2.1.0 中添加icon的配置选项。

例如:

$(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);
            }
        }]);
    });     
});

自定义对话框示例

于 2013-01-29T00:42:24.730 回答
0
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);
    }
});
于 2017-08-01T13:21:45.627 回答