Simple Bootbox message with callback

bootbox.js is a nice simple replacement for alerts. Here’s a quick extension that shows a message by hiding any existing boxes, then showing the new one. Since it’s using Bootstrap’s event-based modals, you have to wait for one to finish loading before closing it or expecting it to be open.

function showMessage(title, body, callback, noButton){
    var data = { title: title, message: body };
    if (callback) {
        data.onShown = callback;
    if (noButton) {
    } else {
showMessage("Loading", "Working...", function () {
    // Do something
    showMessage("Second Message", "This is the real message");
}, true);

Leave a Reply

Your email address will not be published.