sweet-alert: Uncaught ReferenceError: swal is not defined
Hi, Rashid
I had to wrap the alert in a section: (in this case ‘scripts’)
@section('scripts')
@if (alert()->ready())
<script>
swal({
title: "{!! alert()->message() !!}"
});
</script>
@endif
@endsection
And then add:
@yield('scripts')
below my other script files in the layout template to make it work. Otherwise a get an Uncaught ReferenceError: swal is not defined error.
Can you tell me why or is there another workaround to do this?
Thank you for this package!
Richard
Specifications:
- PHP Version: 7.1.9
- Laravel Version: 5.6
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 16 (8 by maintainers)
Hi,
You just add the CDN links in the head section like below
add the yield after the content yield like below
now you can use this with any view that extended the layout
note: in my case the layout file is layout/app.blade.php
Thank you for using the package!