Toaster is throwing an error


Topic: Toaster is throwing an error

Abhayjeet Singh asked 7 years ago

I am getting an error i.e., $.toaster is not a function while using toaster I don't know how to fix it so please tell me what is the problem.  I am using following code:

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Material Design Bootstrap</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="css/mdb.min.css" rel="stylesheet">
<!-- Your custom styles (optional) -->
<link href="css/style.css" rel="stylesheet">

</head>

<body>

<!-- Start your project here-->

<a class="btn btn-info btn-lg" id="alert-target" >Click me!</a>

<!-- /Start your project here-->

<!-- SCRIPTS -->
<!-- JQuery -->

</script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script>
$("#alert-target").click(function () {
toastr["info"]("I was launched via jQuery!")
});
</script>

<script type="text/javascript" src="js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.min.js"></script>
</body>

</html>


Jakub Strebeyko staff answered 7 years ago

Hi Abhayjeet,

There are few things in the code that could use a little improvement. First, the linting issues: font-awesome link (line 10) is not properly closed (a &gt; character entity instead of >). There is a closing </script> tag before any opening one (line 31). Except for that, if you start with a .html file inside the /html/ directory, the file paths are missing the ../ part (necessary to go one directory up and then seek files in /css and /js directories), they should look something like this: <link href="../css/mdb.min.css" rel="stylesheet"> or <script type="text/javascript" src="../js/mdb.min.js"></script&gt;. Getting rid of these few issues allows the button to really shine and toastr around.

With Best Regards,
Kuba


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No