Search code examples
javascriptbootbox

How can I add an option to resize a bootbox alert


How can I add an option to resize a bootbox.alert(); ?

I'm using Bootbox 4.3.0.

bootbox.alert("Success",function(){

});

Here is the link for the bootbox.js library.


Solution

  • You should assign a custom class to your bootbox-alert and change its width on the CSS:

    jQuery:

    bootbox.alert({
          "message": "Success",
          "className" : "my-custom-class",
          "callback": function() {
              console.log("Success callback");
          }
      });
    

    CSS:

    .my-custom-class .modal-dialog{
        width:200px;
    }
    

    This will take your bootbox alert and size it down.

    This is a jsFiddle with the fix you needed.

    If you want all of the alerts to be smaller, just change the original modal-dialog class:

    .modal-dialog{
        width:200px;
    }