简体   繁体   English

禁用Bootbox关闭按钮

[英]Disable the Bootbox close button

I'm wondering how remove the "X" button that shows up on Bootbox alerts, confirms, prompts and dialogs. 我想知道如何删除显示在Bootbox警报,确认,提示和对话框上的“X”按钮。

There are cases where you'd wish to require the user to provide a response--not just dismiss the pop-up with a click on the "X" button. 在某些情况下,您希望要求用户提供响应 - 而不是仅通过单击“X”按钮来关闭弹出窗口。

Does anyone have an idea of how to remove this button? 有没有人知道如何删除此按钮?

I ended up finding the solution, and it is fairly easy (but doesn't seem to be in the current Bootbox documentation.) 我最终找到了解决方案,这很容易(但似乎没有在当前的Bootbox文档中。)

The solution works for Bootbox Dialogs, so if you need to remove the "X" for other types of boxes, I'd suggest imitating the other, more primitive types of boxes as a dialog. 该解决方案适用于Bootbox Dialogs,因此如果您需要删除其他类型的盒子的“X”,我建议将其他更原始类型的盒子模仿为对话框。

The solution, which uses closeButton: false , is seen in the snippet below: 使用closeButton: false的解决方案可以在下面的代码段中看到:

        bootbox.dialog({
            closeButton: false,
            title: "Woah this acts like an alert",
            message: "Cool info for you. You MUST click Ok.",
            buttons: {
                success:{
                    label: "Ok",
                    callback: callback
                }
            }       
        });

       callback(){//stuff that happens when they click Ok.}

By making sure the user must click on a button to dismiss the box, we can make sure they trigger an appropriate callback function. 通过确保用户必须单击按钮来关闭该框,我们可以确保它们触发适当的回调函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM