sweet alert

سلام . من میخوام وقتی حذف کنم از sweet alert بیغام بله یا خیرو ببینم . چجوری میشه ؟ ممنونم


ثبت پرسش جدید
Alimotreb
تخصص : کانفیگ سرور و برنامه نویس
@Alimotreb 5 سال پیش مطرح شد
1

سلام
@rohi1386
از flash message ها میتونید استفاده کنید
تو داکیومنت لاراول هست


سیدعلی موسوی
تخصص : سی شارپ و پی اچ پی
@juza66 5 سال پیش مطرح شد
0

خیلی ساده با این لینک خودمم از لینک استفاده کردم

https://stackoverflow.com/questions/46034634/sweet-alert-confirmation-before-delete


روح اله ابراهیم زاده
تخصص : PHP.LARAVEL
@rohi1386 5 سال پیش مطرح شد
0

نمیدونم چرا کد جاوااسکری\ت تو کدهام کار نمیکنه . وقتی از کدها خارجش میکنم و میبرمش بالای صفحه فعال میشه


روح اله ابراهیم زاده
تخصص : PHP.LARAVEL
@rohi1386 5 سال پیش مطرح شد
0


        function archiveFunction() {
            event.preventDefault(); // prevent form submit
            var form = event.target.form; // storing the form
            swal({
                    title: "Are you sure?",
                    text: "But you will still be able to retrieve this file.",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes, archive it!",
                    cancelButtonText: "No, cancel please!",
                    closeOnConfirm: false,
                    closeOnCancel: false
                },
                function(isConfirm){
                    if (isConfirm) {
                        form.submit();          // submitting the form when user press yes
                    } else {
                        swal("Cancelled", "Your imaginary file is safe :)", "error");
                    }
                });
        }

    </script>``` 

این کدو میزنم ولی اصلا swal اجرا نمیشه اول که \یغام بده

محمد صادقیان
تخصص : برنامه نویس وب - فریم ورک Lara...
@drcode.ir 5 سال پیش مطرح شد
0

اگر منظورتون اینکه که موقع حذف 1 گزینه بله یا خیر رو از کاربر بپرسید می تونید خیلی راحت با JavaScript این کارو بکنید. به شکل زیر :

    function deletee(id) {
      if(confirm('از حذف کاربر مطمئن هستید؟')){
        $('#'+id).submit();
      }
    }

با تعریف تابع در JavaScript و call کردن اون برای دکمه حذف یعنی onClick تعریف کنید براش.


اسدی
تخصص : لاراول
@azhidhak 3 سال پیش آپدیت شد
0

سلام کدتون مربوط به ورژن قدیمی هست از این کد استفاده کنید

function archiveFunction(event) {
        event.preventDefault(); // prevent form submit
        var form = event.target.form; // storing the form
        swal({
           title: "Are you sure?",
  text: "But you will still be able to retrieve this file.",
            icon: "warning",
            buttons: true,
            dangerMode: true,
        })
            .then((willDelete) => {
                if (willDelete) {
                    form.submit();
                } else {
                        swal("Cancelled", "Your imaginary file is safe :)", "error");
                }
            });

    }

رضا جهانگیر
تخصص : Full-Stack Developer
@rezajahangir 3 سال پیش مطرح شد
0

سلام.
من برای حذف یک مقاله مینویسم شما با توجه به پروژتون تغییرش بدین.
ابتدا در فایل اصلی (منظورم همون فایلی که در تمام صفحات پنل کاربری مشترک هست در واقع فایلی که header و footer خودتون رو قرار دادین، کد زیر رو در قسمت footer قرار بدین) کد زیر رو بنویسید.

@if(\Illuminate\Support\Facades\Session::has('status'))
    <script>
        Swal.fire({ title: "{{ session('status') }}", confirmButtonText: 'تایید', icon: 'success'})
    </script>
@endif

کدهای زیر رو در بلید مربوطه قرار بدین.

<a href="{{ route('articles.destroy', $article->id) }}" onclick="destroyArticle(event, {{ $article->id }})"><i class="nav-icon fa fa-trash" style="color: white"></i></a>
<form action="{{ route('articles.destroy', $article->id) }}" method="POST" id="destroy-article-{{ $article->id }}">
    @csrf
    @method('delete')
</form>
<script>
            function destroyArticle(event, id) {
                event.preventDefault();
                Swal.fire({
                    title: 'آیا مطمئن هستید این مقاله را میخواهید حذف کنید؟',
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: 'rgb(221, 51, 51)',
                    cancelButtonColor: 'rgb(48, 133, 214)',
                    confirmButtonText: 'بله',
                    cancelButtonText: 'خیر'
                }).then((result) => {
                    if (result.isConfirmed) {
                        document.getElementById(`destroy-article-${id}`).submit()
                    }
                })
            }
</script>

در کنترلر مربوط به حذف به صورت زیر عمل کنید.

public function destroy(Article $article)
    {
        $article->delete();
        session()->flash('status', 'مقاله با موفقیت حذف شد');
        return back();
    }

موفق باشید.


برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام