Karan Tongay Karan Tongay - 2 months ago 24
CSS Question

How to make bootbox.prompt work?

I had referred the official documentation on this, but still I am not able to get it work. I had imported all the necessary css and js files, but still it doesn't seem to work. I am currently testing on Firefox on ubuntu and Chrome on Windows. Is bootbox compatible with all types of browsers? I am using the latest version of bootbox i.e. 4.x

Following is the piece of code:



$(".alert").click(function(e) {
bootbox.prompt("Hello world!", function(result) {
<!-- Some Code -->
});
});

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<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.7/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootbox/4.4.0/bootbox.min.js"></script>

<body>

<p>Content here. <a class="alert" href=#>Alert!</a></p>

</body>




Answer

I was trying to turn your post into a code snippet and accidentally fixed your problem.

You should be using JQuery 1.9.1 or higher as stated by this error. It looks like your issue lies there and not with bootbox itself.

"message": "Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4".

Updated code below:

    $(".alert").click(function(e) {
    bootbox.prompt("Hello world!", function(result) {
    <!-- Some Code -->
    });
    });
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<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.7/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootbox/4.4.0/bootbox.min.js"></script>

 <body>
      
    <p>Content here. <a class="alert" href=#>Alert!</a></p>

 </body>

Comments