Closed voaneves closed 7 months ago
I've got this too, using the CDN link in an ASP.NET Core application.
@if (TempData["error"] != null)
{
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script type="text/javascript">
toastr.error('@TempData["error"]');
</script>
}
Error in console:
toastr.js:474 Uncaught TypeError: Cannot read properties of undefined (reading 'extend') at m (toastr.js:474:40) at Object.i [as success] (toastr.js:474:40) at Category:54:16
According to the README, jQuery is required. Make sure to import jQuery before toastr, something like this worked for me:
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
Hey there.
I'm using the CDN version of the JS and CSS and tried to have a button like this:
And I got this:
toastr.min.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'extend') at m (toastr.min.js:1:4693) at Object.i [as success] (toastr.min.js:1:432) at HTMLButtonElement.onclick (index.unformatted.html:532:33)
Am I doing anything wrong? I tried to import JQuery too, to no avail.
Thanks!