javascripttwitter-bootstrapcallbackbootbox

Bootbox: Callback function after dismissing the dialog / Clicking on the 'X' button


The following snippet allows me to perform stuff in a callback function for the buttons that are clicked. However, how can I get a callback function, or a similar workaround such that I can perform some code when a user clicks on the 'X' button/dismisses the dialog?

    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.}

I do not want to disable/hide the close button with

closeButton: false,

Solution

  • There is onEscape function for this.

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