Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js event preventdefault continue

//https://codepen.io/UzBekNo1/pen/qBoRPLK

 let lots_of_stuff_already_done = false;
            $('#form_send_pay').submit(function (e) {
                if (lots_of_stuff_already_done) {
                    lots_of_stuff_already_done = false; // reset flag
                    return; // let the event bubble away
                }
                e.preventDefault(); // prevent default click action from happening
                Swal.fire({
                    text              : "Cheking",
                    icon              : 'warning',
                    showCancelButton  : true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor : '#d33',
                    confirmButtonText : 'Ha!',
                    cancelButtonText  : 'Yoq'
                }).then((result) => {
                    // return !!result.isConfirmed;
                    if (result.isConfirmed) {
                        lots_of_stuff_already_done = true; // set flag
                        $('#form_send_pay').submit();
                    }
                });
            });
Source by codepen.io #
 
PREVIOUS NEXT
Tagged: #js #event #preventdefault #continue
ADD COMMENT
Topic
Name
4+5 =