Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting error Uncaught ReferenceError: BootstrapDialog is not defined

I'm trying to use Bootstrap's modal to send tweets. I downloaded modal.js and bootstrap.min.js into my JavaScript file, but I'm getting the error:

Uncaught ReferenceError: BootstrapDialog is not defined.

Anyone know what I'm doing wrong?

HTML:

<script src="js/bootstrap.min.js"></script>
<script src="js/modal.js"></script>
<script src="js/scripts.js"></script> <!-- my jquery file -->

JavaScript:

setTimeout(function() {
    BootstrapDialog.alert('I want banana!');
}, 1000);
like image 635
LauraNMS Avatar asked Feb 10 '15 16:02

LauraNMS


5 Answers

You're calling a plugin BootstrapDialog (https://github.com/nakupanda/bootstrap3-dialog) but not including it in your JS files. You're not using only the Bootstrap default modal (http://getbootstrap.com/javascript/#modals)

like image 131
Jeremy Thille Avatar answered Nov 02 '22 01:11

Jeremy Thille


You need to source the bootstrap-dialog.min.js file somewhere before your JavaScript runs.

like image 44
amphetamachine Avatar answered Nov 02 '22 03:11

amphetamachine


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>
like image 37
Waqar Detho Avatar answered Nov 02 '22 01:11

Waqar Detho


setTimeout(function(){
    BootstrapDialog.alert('I want banana!');
}, 1000);

also you have to include this script in your main html file.

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>  
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css"> 

Also do keep a track on the order in which you are including these scripts.

NOTE:-THIS SOLUTION WORKED FOR ME IT MAY OR MAY NOT WORK FOR YOU.

like image 35
Sanket Avatar answered Nov 02 '22 02:11

Sanket


Just add both to the head section

https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css

https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js
like image 1
Suhail Mumtaz Awan Avatar answered Nov 02 '22 02:11

Suhail Mumtaz Awan