javascript - Bootbox:关闭对话框/点击 'X'按钮后的回调函数

标签 javascript twitter-bootstrap callback bootbox

下面的代码片段允许我在被点击的按钮的回调函数中执行一些操作。但是,如何获得回调函数或类似的解决方法,以便在用户单击“X”按钮/关闭对话框时执行一些代码?

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

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

我不想禁用/隐藏关闭按钮

closeButton: false,

最佳答案

为此有一个 onEscape 函数。

bootbox.dialog({
    message: 'the msg',
    title: "Title",
    onEscape: function() {
        // you can do anything here you want when the user dismisses dialog
    }
}); 

关于javascript - Bootbox:关闭对话框/点击 'X'按钮后的回调函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29113222/

相关文章:

matlab - 是否可以在 WindowButtonMotionFcn 中使用多个回调?

javascript - Highchart datepicker范围选择器,可以动态选择要显示的数据

html - 我需要在网页上居中 3 <div>

javascript - 要在编辑按钮上自动填充文本框中的值,请单击并编辑/更新 HTML 表单中的值

javascript - jquery:单击按钮时未收到回调

Javascript:有没有办法在没有 eval() 的情况下使用字符串作为回调?

javascript - 如何将实时 dom 元素数组转换为实时 NodeList?

javascript - 如何在同一个提交按钮中放置一个 onclick 和一个 return false 语句?

java - PhoneGap : Inject JS into HTML on page load through Java on Android

twitter-bootstrap - Initializr 上的 "Mobile-first Responsive"和 "Twitter Bootstrap"有什么区别?