jantinnerezo / livewire-alert

SweetAlert2 wrapper for Livewire
https://livewire-alert.jantinnerezo.com
MIT License
709 stars 73 forks source link

Error sweetAlert2 #59

Closed Fred7877 closed 2 years ago

Fred7877 commented 2 years ago

Hello @jantinnerezo !

I get a sweetAlert2 error in the javascript console when I use alert() or confirm():

sweetalert2@10:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then') at i.value (sweetalert2@10:1)

I have tested with sweetalert2@11, same thing.

I don't know if you can do anything or if you know about this mistake...

Regards,

jantinnerezo commented 2 years ago

Hi @Fred7877, can you show me how you import sweetalert2 and livewire alert scripts?

Fred7877 commented 2 years ago
@extends('layouts.admin')

@section('content_admin')
    {{$dataTable->table()}}
@stop

@push('js')

    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <x-livewire-alert::scripts />

    <script src="{{ asset('vendor/livewire-alert/livewire-alert.js') }}"></script>
    <x-livewire-alert::flash />

    {{$dataTable->scripts()}}

@endpush
jantinnerezo commented 2 years ago

You can just either import <x-livewire-alert::scripts /> or <script src="{{ asset('vendor/livewire-alert/livewire-alert.js') }}"></script>

because you are importing the script twice.

You can check the demo repo: https://github.com/jantinnerezo/livewire-alert-demo/blob/main/resources/views/layouts/master.blade.php

jantinnerezo commented 2 years ago

When using <x-livewire-alert::scripts />, you don't need to include the <x-livewire-alert::flash /> anymore.

Fred7877 commented 2 years ago

Thanks ! it's clear the error message :)

Regards,

jantinnerezo commented 2 years ago

Great! closing it now. Thanks!