“So verwenden Sie Sweetalert in Laravel Controller” Code-Antworten

So verwenden Sie Sweetalert in Laravel Controller

@if (Session::has('sweet_alert.alert'))
<script>
  swal({!! Session::get('sweet_alert.alert') !!});
</script>
@endif
Friendly Flamingo

SweetAlertbox in Laravel

-> npm install sweetalert2

->resources/app.js
	window.Swal = require("sweetalert2");
    
->resources/sass/app.scss
	@import "~sweetalert2";
    
    
->you must carry with "with method" in Controller
	return redirect()->route('index')->with('status',"You $contact->name Updated")
    
->resources/view/layouts/app.blade.php
	@if(session('status'))
        <script>
            const Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000,
                timerProgressBar: true,
                didOpen: (toast) => {
                    toast.addEventListener('mouseenter', Swal.stopTimer)
                    toast.addEventListener('mouseleave', Swal.resumeTimer)
                }
            })

            Toast.fire({
                icon: 'success',
                title: '{{session('status')}}'
            })
        </script>
    @endif
  
  
  
-> https://sweetalert2.github.io/
WinMaw

sweetalert laravel

<script src="https://unpkg.com/[email protected]/dist/sweetalert2.all.js"></script>
Determined Dormouse

süßer Alarm bestätigen Box Laravel

$(document).on('click', '.button', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    swal({
            title: "Are you sure!",
            type: "error",
            confirmButtonClass: "btn-danger",
            confirmButtonText: "Yes!",
            showCancelButton: true,
        },
        function() {
            $.ajax({
                type: "POST",
                url: "{{url('/destroy')}}",
                data: {id:id},
                success: function (data) {
                              //
                    }         
            });
    });
});
Crazy Capybara

süßer Alarm bestätigen Box Laravel

<a href="" class="button" data-id="{{$user->id}}">Delete</a>
Crazy Capybara

Ähnliche Antworten wie “So verwenden Sie Sweetalert in Laravel Controller”

Fragen ähnlich wie “So verwenden Sie Sweetalert in Laravel Controller”

Weitere verwandte Antworten zu “So verwenden Sie Sweetalert in Laravel Controller” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen