Fork me on GitHub

Bootbox.js—alert, confirm and flexible dialogs for Twitter's Bootstrap framework

Bootbox.js is a small JavaScript library which allows you to create programmatic dialog boxes using Twitter's Bootstrap modals, without having to worry about creating, managing or removing any of the required DOM elements or JS event handlers. Here's the simplest possible example:

Compare that to the code you'd have to write without Bootbox:

The library exposes three methods designed to mimic their native JavaScript equivalents:

These methods all invoke a fourth method, dialog, which allows you to create your own modals with any number of buttons and event handlers.

For a lot more information, head over to the tutorial and subsequent update for Bootstrap 2.x.x releases.

Examples

Please Note that these demos are extremely crude—please feel free to fork the project and improve them. You can view the source for this demo page to get a better understanding of the minimal code required to show each dialog.

Very few of the buttons will appear to do anything other than dismiss the dialog—be sure to view your browser's console output for some useful debug information.

Download

The latest stable version of bootbox is v2.5.1. You can download the minified library bootbox.min.js for use in production, or the uncompressed bootbox.js for use in development. I wouldn’t recommend hotlinking to either file as Github does not serve the correct mime type which may cause unexpected issues.

If you wish you may also see a full list of available downloads or download the latest copy of the entire repository (including build files and tests) in zip or tarball format.

Usage

In rough DOM order:

  1. Include bootstrap.css >= 2.0.0
  2. Include jquery.js >= 1.7.1
  3. Include bootstrap.js >= 2.0.0
  4. Include bootbox.min.js

What else?


Made by @makeusabrew. Licensed under the MIT License.