javascript Confirm replacement with return true/false
By : mjl
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further jQuery UI can do what you want, you simply have to adjust your code to work in an async way. Ariel Popovosky gave an answer which attempts to wrap a dialog call into a simple function call, and would work well but would require the same basic sync/async code modifications that any change from window.confirm would require. Using window.confirm we use a synchronous way of doing things--program halts while user makes a decision. See example: http://jsfiddle.net/9jY7E/
|
enable an input field on confirm true return
By : Ravi 123
Date : March 29 2020, 07:55 AM
|
Javascript: Trigger if confirm return true from different function
By : VINCENT FRANCISCO
Date : March 29 2020, 07:55 AM
may help you . I would suggest you modularize your code by putting the logic you want to use in two places in a function that both places can call: code :
// The function doing the thing
function doTheThing(/*...receive arguments here if needed...*/) {
// ...
}
$('#button1').on('click', function(){
if(confirm("Are you sure?")){
doTheThing(/*...pass arguments here if needed...*/);
}else{
return false;
}
});
$('.button2').on('click', function(){
//if the confirm condition from first function return true
//i need to fire here as well without doing another if(confirm)
doTheThing(/*...pass arguments here if needed...*/);
});
(function() {
// The function doing the thing
function doTheThing(/*...receive arguments here if needed...*/) {
// ...
}
$('#button1').on('click', function(){
if(confirm("Are you sure?")){
doTheThing(/*...pass arguments here if needed...*/);
}else{
return false;
}
});
$('.button2').on('click', function(){
//if the confirm condition from first function return true
//i need to fire here as well without doing another if(confirm)
doTheThing(/*...pass arguments here if needed...*/);
});
})();
|
How to have sweetalert return true/false for confirm without promise?
By : user1423557
Date : March 29 2020, 07:55 AM
it fixes the issue By design, SweetAlert uses Promises to keep track of how the user interacts with the HTML-based alert and it's non-blocking (you can still interact with the webpage/UI) as opposed to the browser's built-in confirm() method, which, when displaying the modal window, it prevents the user from accessing the rest of the program's interface until the dialog box is closed. code :
if (!await swal({text: 'Are you sure?', buttons: true})) {
return;
}
async function confirm(message) {
return swal({
text: message,
buttons: true
});
}
if (!await confirm('Are you sure?')) {
return;
}
document.addEventListener('DOMContentLoaded', async () => {
// ... await and other async code here
});
(async () => {
// ... await and other async code here
})();
|
Confirm() always return true?
By : Mushtaq Ahmad web de
Date : March 29 2020, 07:55 AM
To fix this issue It doesn't always return true. Your script just always runs the same code regardless. It's equivalent to this:
|