Noodlewitt
1/25/2016 - 2:08 AM

confirm button function

confirm button function

<script>
            $('.js-confirm').click(function(e){
                e.preventDefault();
                $me = $(this);
                swal({
                    title: $me.data('swal-title'),
                    text: $me.data('swal-text'),
                    type: $me.data('swal-type'),
                    confirmButtonText: $me.data('swal-confirmbutton'),
                    cancelButtonText: "Cancel",
                    showCancelButton: true
                },
                function(isConfirm){
                    if (isConfirm) {
                        if($me.is("input")){
                            $me.closest('form').submit();
                        }
                        else{
                            $(location).attr('href', $me.attr('href'));
                        }
                    } else {
                        //do nothing
                    }
                });
            });

        </script>