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");
}
})
}
$('.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
Post a Comment