ua_boaz ua_boaz - 7 months ago 31
Javascript Question

bootbox 4.4 how to alert with different button label

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

Answer

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

Comments