首页 > 解决方案 > 需要区分 bootbox.alert() 和 bootbox.confirm() 两种样式的modal在同一个页面

问题描述

我在同一页面中有多个 bootbox.alert() 和 bootbox.confirm() 模态需要清楚地添加不同的样式但到目前为止还没有运气,如何为这些模态定义自己的样式类。

var alertModal = bootbox.alert(
                {
                    title: "<i class='fa fa-exclamation-circle' style='font-size: 20px; color: white'></i> Alert",
                    message: "Please select Patient from Queue",
                })
            alertModal.find('.modal-header')
                .css(
                {
                    'background-color': 'red',
                    'color': 'white'
                }
                );
            alertModal.find('.modal-footer')
                .css({
                    'background-color': 'green',
                    'color': 'white'
                }
                );

标签: cssbootbox

解决方案


在文档链接Dialog Options中,您可以看到,给出了可选 className 的选项。

var alertModal = bootbox.alert(
{
    title: "<i class='fa fa-exclamation-circle' style='font-size: 20px; color: white'></i> Alert",
    message: "Please select Patient from Queue",
    className:"your custom class name here"
})

您可以为警报创建单独的类并确认并将其传递到选项中


推荐阅读