bootbox js对话框的图标

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

Custom dialog example


1
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);
    }
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接