How to call another function on confirm box return value.
Below is the code I am working with, here it goes to else part only. And when I click confirm box 'yes' button its not calling the function abc. TIA.
jQuery :-
var result = confirm('Are you sure');
if (result) {
abc(); //another jquery function call
}
else {
}
I have also tried writing on browser console but it writes false only.
var result = confirm('Are you sure');
if (result) {
console.log('true');
} else {
console.log('false');
}
I am using sweet alert plugin, may be getting problem from that. My confirm function is given below.
function confirm(title) {
var returnType = false;
swal({
title: "Warning",//"Are you sure?",
text: title,
//text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm, id) {
if (isConfirm) {
//window.location.href = href;
returnType = true;
//swal("Deleted!", "Record has been deleted.", "success");
} else {
//$('div').click();
//$('#' + clientid).blur();
returnType = false;
//swal("Cancelled", "Your imaginary file is safe :)", "error");
}
}
);
return returnType;
}