Sweet Alert Warning & Updating record

Remove a member
$('.remove-member').on("click", function(ev){
    ev.preventDefault();
    var URL = $(this).attr('href');
    var redirectURL = "{{ url('/tele-sales/team/open/'.$team->id) }}";
    warnBeforeRemoveMember(URL, redirectURL);
});

Warn before remove member and redirect
function warnBeforeRemoveMember(URL, redirectURL) {
    swal({
        title: 'Are you sure?',
        text: "You won't be able to revert this!",
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Yes, Remove',
        cancelButtonText: 'No, Cancel!',
        confirmButtonClass: 'btn btn-success',
        cancelButtonClass: 'btn btn-danger',
        buttonsStyling: true,
        reverseButtons: true
    }).then(function(isConfirm) {
        if (isConfirm.value) {
            $.ajax({
                type: "GET",
                url: URL,
                headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                success: function(){
                    swal("Submitted!", "Member removed from this team successfully !", "success");
                    window.location.href = redirectURL;
                }
            })
        } else {
            swal("Cancelled", "Action Cancelled.", "error");
        }
    })
}

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine