twitter-bootstrapbootbox

Bootstrap and bootbox: dynamically change the width of confirmation window


I am using Bootstrap for a web application and using bootbox (http://bootboxjs.com) for showing a window before proceeding with a delete operation.

For different delete options, I need to display different messages. I would like to show confirmation windows with different widths.

How can I do this dynamically in javascript code? I looked at everything and am unable to find a solution.

Thanks for any ideas and suggestions!

Cheers.


Solution

  • It is possible to add custom classes to bootbox windows with 'bootbox.classes'. I think you should make some standard CSS classes like small, medium, large and asign a width in CSS.

    Then in every bootbox use a line like below (e.g.):

    bootbox.classes.add('medium');
    

    According to the the documentation bootbox.classes is a helper method, so it should work. http://bootboxjs.com/documentation.html

    It seems to be taken out of the documentation, I have no clue if above method still works.

    Below is another implementation to add your own class to a dialog (e.g.):

    bootbox.dialog({
    
      message: "I am a custom dialog",
      animate: true,
    
      /**
       * @optional String
       * @default: null
       * an additional class to apply to the dialog wrapper
       */
      className: "medium"
      }
    });