API Documentation

This documentation is rather dry, not particularly well organised and incomplete. If you want to help out then please fork & edit this page!

Documentation for older versions of Bootbox is also available: v3.x, v2.x.

Please note that the usage shown for the three main wrapper methods alert, confirm and prompt is the most basic available; each method can also take a single options object in which case many of the options shown in the bootbox.dialog example can also be supplied.

bootbox.alert(…)

A simple alert dialog with a single button. Pressing escape or clicking the close button dismisses the dialog. If a callback is provided it is not passed any value when executed.

Usage Result
bootbox.alert(str message) Dialog with default 'OK' button
bootbox.alert(str message, fn callback) Default button text, callback invoked on dismissal
bootbox.alert(object options) Object property names as above

bootbox.confirm(…)

A confirm dialog with a cancel and a confirm button. Pressing escape or clicking close dismisses the dialog and invokes the callback as if the user had clicked the cancel button. If a callback is provided it is passed a value of true or false depending on which button the user pressed.

Usage Result
bootbox.confirm(str message, fn callback) Default 'Cancel' and 'OK' buttons, callback invoked on dismissal
bootbox.confirm(object options) Object property names as above

bootbox.prompt(…)

A dialog which prompts for user input. Pressing escape or clicking close dismisses the dialog and invokes the callback as if the user had clicked the cancel button. If a callback is provided it is passed a value of null if the user cancels or dismissed the dialog, otherwise it is passed the value of the text input.

Usage Result
bootbox.prompt(str title, fn callback) Default 'Cancel' and 'OK' buttons, callback invoked on dismissal
bootbox.prompt(object options) Object property names as above

bootbox.dialog(…)

A completely customisable dialog method which takes a single argument; an options object. The following snippet attempts to demonstrate these options as best as possible, though more formal documentation would be welcome:

bootbox.setDefaults(object options)

This method allows the user to set many of the default options shown in the previous dialog example. Many of these options are also applied to the basic wrapper methods and can be overridden whenever the wrapper methods are invoked with a single options argument:

bootbox.hideAll()

Hide all currently active bootbox dialogs. Individual dialogs can be closed as per normal Bootstrap dialogs: dialog.modal('hide').

This documentation is rather dry, not particularly well organised and incomplete. If you want to help out then please fork & edit this page!

© 2011-2014 Nick Payne. I run a small company—why not see if you want to work with us?