Reputation: 9273
I'm trying to use the Bootbox plugin, but I can't make it work, this is my import code:
<script src="jquery.min.js" type="text/javascript"></script>
<script src="bootstrap.min.js" type="text/javascript"></script>
<script src="ui-bootbox.min.js" type="text/javascript"></script>
then HTML:
<p>Content here. <a class="alert" href=#>Alert!</a></p>
and Javascript:
$(document).on("click", ".alert", function(e) {
bootbox.alert("Hello world!", function() {
console.log("Alert Callback");
});
});
But when I click the link, this is the error in the console:
ReferenceError: Can't find variable: bootbox
how I can to fix this?
thanks
Upvotes: 0
Views: 434
Reputation: 19113
The problem is your bootbox.js
is corrupted. Get a copy from the cdn. It should work.
$(document).on("click", ".alert", function(e) {
bootbox.alert("Hello world!", function() {
console.log("Alert Callback");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.js"></script>
<p>Content here. <a class="alert" href=#>Alert!</a>
</p>
Upvotes: 2