2

私のSweetAlert確認は何のアクションも待っていません. 確認ボックスが点滅するだけで、アクションが実行されます。どうしたの?

<script type="text/javascript">
    function confirmDelete() {
        swal({
            title: "Are you sure?",
            text: "You will not be able to recover this imaginary file!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Delete",
            cancelButtonText: "Cancel",
            closeOnConfirm: false,
            closeOnCancel: false
        });
    }
</script>

<form onsubmit="confirmDelete()" action="index.php" method="post">
    <button type="submit" name="delete">Delete</button>
</form>

これも試しました。同じ問題...ウィンドウが点滅し、アクションが実行されます。

<script type="text/javascript">
    function confirmDelete() {
        swal({
            title: "Are you sure?",
            text: "You will not be able to recover this imaginary file!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Delete",
            cancelButtonText: "Cancel",
            closeOnConfirm: false,
            closeOnCancel: false
        },
        function(isConfirm) {
            if (isConfirm) {
                document.deleteForm.submit();
            }
        });
    }
</script>

<form id="deleteForm" action="index.php" method="post">
    <button onclick="confirmDelete()" type="input" name="delete">Delete</button>
</form>
4

2 に答える 2