2

i see in bootbox v3 documentation you can change the label by using below method bootbox.alert(str message, str label, fn callback) Custom button text, callback invoked on dismissal,

However on version 4.4 this method does not seem to work, how can i get to use a custom button label on alert message

josh_boaz
  • 1,963
  • 7
  • 32
  • 69

2 Answers2

9

You can override the text for any dialog, using the buttons option (which does require you to use an options object to setup your dialog). For example, here's a custom alert:

$(function() {
  bootbox.alert({
    message: 'I have a custom OK button',
    buttons: {
      ok: {
        label: 'Right on!'
      }
    }
  })
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>

For confirm and prompt, you can override confirm and cancel as buttons.

Tieson T.
  • 20,774
  • 6
  • 77
  • 92
1

You can try something like this:

bootbox.alert({ 
   size: 'small',
   message: "Your message here…", 
   callback: function(){ /* your callback code */ }
}).init(function(){ 
    $('.btn.btn-primary').text('Custom Text')
});

From the docs: bootbox.init(function): Allows the user to supply a function to be called when dialog gets initialized. http://bootboxjs.com/documentation.html#bb-public-methods

Hackerman
  • 12,139
  • 2
  • 34
  • 45