A small javascript module for creating bootstrap 4 dialog windows.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A small javascript module for creating bootstrap 4 modal dialog windows.


Instead of writing code like this:

<div class="modal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

…you may just write something like:

  title: 'Modal title',
  message: '<p>Modal body text goes here.</p>',
  buttons: [
      label: 'Close',
      action: function(atr) { atr.close(); }

…or even:

bsWindow.alert('Modal body text goes here', 'Title');

Usage (module methods)


A simple alert window, like native javascript alert.

Usage: bsWindow.alert(text, title, cb);.


  • text — Message text.
  • titleOptional. Message title.
  • cbOptional. Callback function, that fired after the dialog will be closed.


Another analog of native javascript function confirm.

Usage similar: bsWindow.confirm(text, title, cb);.

The user choice will be passed to the callback attribute as boolean value.


And another one analog of native JS function.

Usage: bsWindow.prompt(text, defaultValue, title, cb);.

The user's answer will be passed to callback the same way as it native JS function do (if user cancelled dialog window, there will be null).

More complex modal dialogs

Usage: bsWindow.show(options);.

Where options is an object, containing the following settings (All of them are optional):

  • title — Window title.
  • message — Window message.
  • animate — Window animation. Default true.
  • large — Window large width. Default false.
  • small — Window small width. Default false.
  • closeable — Window closeable. Default true.
  • buttons — Array of button objects, each of them may have the following settings:
    • label — Label text of button.
    • className — A string that will be added to class attribute of button. Default: btn-secondary.
    • actionOptional. A callback function, that fired when user clicks a button.
  • onAppear — Callback function, that fired when window did appear.
  • onDisappear — Callback function, that fired when window did disappear.

Every callback function (button action or onAppear/onDisappear) gets object with following properties as attribute:

  • element — DOM element of dialog window itself.
  • close — A function, implemented to close window, if needed. It will destroy the generated DOM elements of modal dialog.