I am trying to use sweet alert to as a replacement for the standard JavaScript confirm dialog box. The issue I am experiencing is when I return the promise the method does not wait for the response it simply ends the tour.
I would like to see this method accept a promise and wait for the response. Is this possible?
I would expect after clicking no on the sweetAlert modal, that i would be returned to the tour as when using the standard javascript confirm('') method as shown here
Introjs().onbeforeexit(function() {
var alertText;
if (instance.data.whatstep < steps.length){
alertText = 'Are you sure you want to leave the tour early'
} else {
alertText = properties.alert_text
}
var r = confirm (alertText)
if (r == true){
console.log('exit')
if ( instance.data.whatstep < steps.length ){
console.log('leaving early')
instance.triggerEvent("user_left_tour")
} else {
console.log('not leaving early')
instance.triggerEvent("user_finished_tour")
}
return r
} else {
console.log('dont exit')
return r
}
});
here is the 'onbeforeexit()' code I am trying to use that doesn't work
Introjs().onbeforeexit(function() {
const r = async function confirm(message) {
return swal({
text: 'are you sure',
buttons: true
});
}
console.log(r())
return r()
}).start();