Open prwinkmr opened 4 years ago
Not sure I 100% understand what you're asking, but I think await
is what you want? For example:
async function ask() {
let x = await swal({
title: "Are you PK?",
buttons: ["no","yes"]
});
if (x) {
console.log("Welcome PK!!!");
}
}
ask();
if(name==="PK"){ x=true; } else{ //after this alert is on screen I want execution of to be freezed until I get a response from user // if she/he will click yes I can assign true to x in callback or else false and then I want to proceed // this freezing is required because if by default name is PK then no need to display alert // If I am unable to freeze till response I am forced to repeat the code. //Please suggest some solution to this swal("Query","Are you PK",...) }
if(x){ console.log("Welcome PK!!!"); }