Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line in Bootbox Alert box

I would like to make a new line in my Bootbox Alert Box. I know in Javascript you can use \n but this doesn't seem to work. Here is what I have tried:

bootbox.alert("Hello \n world");
like image 852
user3399863 Avatar asked May 19 '15 10:05

user3399863


People also ask

How do you add a new line in alert box?

To add a new line to the content of alert box we are going to use \n backslash(n).

How do I remove the delete button from Bootbox confirmation?

The solution, which uses closeButton: false , is seen in the snippet below: bootbox. dialog({ closeButton: false, title: "Woah this acts like an alert", message: "Cool info for you. You MUST click Ok.", buttons: { success:{ label: "Ok", callback: callback } } }); callback(){//stuff that happens when they click Ok.}

How do I close Bootbox dialog?

Pressing the ESC key or clicking close () dismisses the dialog and invokes the callback as if the user had clicked the Cancel button. Confirm dialogs require a callback function.

What is a Bootbox and how it is generated?

js is a small JavaScript library which allows you to create programmatic dialog boxes using Bootstrap modals, without having to worry about creating, managing, or removing any of the required DOM elements or JavaScript event handlers. npm i bootbox • cdnjs.


2 Answers

You can use html for that:

bootbox.alert("Hello <br> world!");

Will do it

like image 125
monxas Avatar answered Oct 14 '22 05:10

monxas


with confirm message

$(function () {
    $(".confirm").click(function (e) {
        e.preventDefault();
        bootbox.confirm({
            message: "<h3>Hello</h3> <br> world!",
            buttons: {
            confirm: {
                label: 'yes',
                className: 'btn-success'
            },
            cancel: {
                label: 'no',
                className: 'btn-danger'
            }
        },
        callback: function (result) {
            if (result)
                console.log('yes');
        }
        });
        
    });
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-1.11.3.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>

<a href="http://www.example.com/" action="deleteElement" class="btn btn-danger confirm">Delete</a>
like image 21
mohamed elshazly Avatar answered Oct 14 '22 06:10

mohamed elshazly