28 June 2023

How to use sweet alert (Trash Sweet Alert) before redirect link?

 <button type="btn" class="btn_cancel deleteOnElement" type="button" data-route="{{ route('cancel-order', $order_id) }}">Cancel</button>


<!-- sweet alert -->

 <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>


<script type="text/javascript">

//end application user type

$(document).on('click','.deleteOnElement', function(event)

{

      var route  = $(this).data('route');

      //alert(route);

      swal({

        title: "Confirm Trash",

        text: "Are you sure you want to cancel this request? ",

        icon: "warning",

        buttons: true,

        dangerMode: true,

      })

      .then((willDelete) => {

        if (willDelete) {

          window.location.replace(route);

        } else {

          swal("Your data is safe!");

        }

      });          

});

</script>

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...