最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable the Bootbox close button - Stack Overflow

programmeradmin1浏览0评论

I'm wondering how remove the "X" button that shows up on Bootbox alerts, confirms, prompts and dialogs.

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.

Does anyone have an idea of how to remove this button?

I'm wondering how remove the "X" button that shows up on Bootbox alerts, confirms, prompts and dialogs.

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.

Does anyone have an idea of how to remove this button?

Share Improve this question asked Jun 23, 2014 at 17:11 EctropyEctropy 1,5414 gold badges22 silver badges37 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 41

I ended up finding the solution, and it is fairly easy (but doesn't seem to be in the current Bootbox documentation.)

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.

The solution, which uses closeButton: false, is seen in the snippet below:

        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.

发布评论

评论列表(0)

  1. 暂无评论