【问题标题】:How to use Sweetarlet2 delete?如何使用 Sweetalert2 删除?
【发布时间】:2020-11-07 22:00:18
【问题描述】:

我有一个问题,我正在学习如何使用 sweetarlet2,我正在使用 spring 项目。我想在删除它之前制作一个有 arlet 的按钮。 这是我的 HTML 按钮。

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#delete" onclick="deleteArlet('+${ps.nama}+ ')"> delete </button> 

这里是我的 js 脚本。

<script>
                    function deleteArlet(id){
                    Swal.fire({
                    title: 'Are you sure?',
                    text: "You won't be able to revert this!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, delete it!'
                    }).then((result) => {
                        if (result.value) {
                            url: "/siswa/delete/"+ Id,
                                    data: { Id: Id }
                            Swal.fire(
                            'Deleted!',
                            'Your file has been deleted.',
                            'success'
                        )
                    }
                    })
                    }

【问题讨论】:

    标签: javascript html css spring sweetalert2


    【解决方案1】:

    尝试使用if(result.isConfirmed) 而不是if (result.value)。对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-19
      • 1970-01-01
      • 2021-10-28
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多