Swal value is passing when isConfirmed is true and value is false if isConfirmed is false

27 Views Asked by At

The below is my script when I type something and press Yes Recieved the output is like this

{isConfirmed: true, isDenied: false, isDismissed: false, value: 'hello'}

if I press Din't Recieve the value is also set to flase and the value is not showing why

{isConfirmed: false, isDenied: true, isDismissed: false, value: false}

I using sweetalreat 2.11

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
   $(document).on('click', '.received-money-btn', function() {
            var rowData = $('#myDataTable').DataTable().row($(this).closest('tr')).data();
            var headOfAccount = rowData['head_of_account'];
            var amount = rowData['amount'];
            var id = rowData['payment_order_id'];
            Swal.fire({
                title: 'Confirmation',
                html: 'Did you receive the money from <br><strong>' + headOfAccount + ' - ₹' + amount +
                    '</strong> ?',
                icon: 'question',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, received!',
                showDenyButton: true,
                denyButtonText: "Didn't Receive",
                allowOutsideClick: false,
                input: 'text',
                inputPlaceholder: 'Enter remark (if not received)',
            }).then((result) => {
                console.log(result);
                if (result.isConfirmed) {
                    handleReceived(id);
                } else if (result.isDenied) {
                    console.log(result.value);
                    handleNotReceived(id, result.value);
                } else {
                    Swal.fire('Cancelled', 'You have cancelled the operation.', 'info');
                }
            });
        });

This is my script and I try to pass data to my function.

0

There are 0 best solutions below