bootbox js对话框的图标

时间:2013-01-28 23:15:56

标签: twitter-bootstrap

有没有人想出如何在bootbox.js对话框中为按钮添加图标?我想在" No"中添加图标。和"是"此功能中的按钮:

$(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 个答案:

答案 0 :(得分:3)

您需要创建自定义对话框并使用icon配置选项added in 2.1.0

例如:

$(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 :(得分: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);
    }
});