“cara menggunakan sweetalert di controller laravel” Kode Jawaban

cara menggunakan sweetalert di controller laravel

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

Sweetalertbox di 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

peringatan manis konfirmasi 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

peringatan manis konfirmasi box laravel

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

Jawaban yang mirip dengan “cara menggunakan sweetalert di controller laravel”

Pertanyaan yang mirip dengan “cara menggunakan sweetalert di controller laravel”

Lebih banyak jawaban terkait untuk “cara menggunakan sweetalert di controller laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya