Bootbox.js – alert, confirm and flexible dialogs

Bootbox.js is a nice lets call it JavaScript library for creating alert, confirm and flexible dialogs. Bootbox is Twitter Bootstrap powered and has been build to replace the crude behavior and wildly varying appearance between browsers. The result is this library that combines the basic functionality with bootstrap’s slick looking dialog boxes.

Bootbox.js is very easy to use and the results are awesome. For example, to creat a simple alert you just need to write …

bootbox.alert("Hello world!");

… and to make a simple alert but with a callback function you simply need to write ….

bootbox.alert("Hello World!", function() {
    // any code you want to happen after the alert is dismissed
    console.log("Alert dismissed");
});

You can also change the button labels to match your preferences, and all you need to write is…

bootbox.alert("Custom label text!", "Very good.");

To wrap it up, there are a lot of configuration you can use with bootbox.js and the results are various and awesome. You can check all of this on the configuration page here

Bootbox.js – alert, confirm and flexible dialogs – Sample

Bootbox - Alert, confirm and flexible dialogs

List of Demos Configuration and Download Page

2 Comments

  1. malinga

    11.17.2012

    Reply

    i have written a php code…

    // If click check the session is set or not
    if(isset($_POST[‘reserve’])){
    if(!empty($_SESSION[‘username’])){

    $db->query(“INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES (‘$book_id’,’$userId’,’$date’)”);

    }else{
    echo ‘ ‘; // I nee to display alert box here
    }
    }

    if session not start alert msg should be displayed. how can i do it? i tried like this. but it didn’t work.

    if(isset($_POST[‘reserve’])){
    if(!empty($_SESSION[‘username’])){

    $db->query(“INSERT INTO `reserve` (`r_b_id`,`r_m_id`,`r_date`) VALUES (‘$book_id’,’$userId’,’$date’)”);

    }else{
    echo ‘$(document).load(function(){
    bootbox.alert(“You must login first”);
    }); ‘;
    }
    }

    • Bogdan

      11.19.2012

      Reply

      Hi,

      When you echo the $(document).load bit, that needs to be inside a . Also, you need to trigger the bootbox event itself and not just pasted it. I would recommend that you already have it on your source code and only trigger the “bootbox.alert” event.

Leave a Reply