inconsistent behaviour: form not always being saved
See original GitHub issueWhenever I submit a form it is not being saved consistently when using sweet alert. Between 2 and 5 submits the form suddenly fails to save. Have tried in many ways but all seem to suffer from the same issue (some examples provided below). For example, I submit the form and it can saved, the first time, the second time, and the third time suddenly the forms are not being saved.
<script>
$('#btn-sw-confirmation').on('click', function() {
swal({
title: "Confirm?",
text: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#41B314',
cancelButtonColor: '#F9354C',
confirmButtonText: "Confirm",
cancelButtonText: "Back"
}
).then(
function (isConfirm) {
if (isConfirm) {
console.log('CONFIRMED');
swal('Saved!', 'Your file has been saved.', 'success');
}
},
function() {
console.log('BACK');
});
return false;
});
</script>
or
<script>
$('#btn-sw-confirmation').on('click', function() {
swal({
title: "Confirm?",
text: "Are you sure?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Confirm",
cancelButtonText: "Back",
showLoaderOnConfirm: true,
}
).then((isConfirm) => {
if (isConfirm) {
console.log('CONFIRMED');
swal('Saved!', 'Incident reported.', 'success');
}
},
function() {
console.log('BACK');
});
return false;
});
</script>
or
<script>
$('#btn-sw-confirmation').on('click', function (e) {
e.preventDefault();
swal(
{
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#41B314',
cancelButtonColor: '#F9354C',
confirmButtonText: 'Yes, save it!'
}
).then(swal(
'Saved!',
'Incident reported.',
'success'
)
).catch(swal.noop);
});
</script>
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Tired of inconsistency in relationships? Signs of emotional ...
Inconsistent behaviour is nothing less than a form of emotional abuse. And we often come across people who exhibit emotional inconsistency.
Read more >Inconsistency in Relationships is a Form of Emotional Abuse
If a person is consistently inconsistent, the behavior is likely to be conscious. We're not always going to be in a good mood....
Read more >The Time Inconsistency Problem and How It's Hurting You
Time inconsistency is how our behavior and desires change over time. ... We all know that saving money and not eating cookies can...
Read more >Save in State inconsistent behavior · Issue #2779 · formio ...
I have a form where i am using my own onSubmit function. However, the feedback to the user is inconsistent, and I'm not...
Read more >Inconsistent behaviour for HTML patterns - Stack Overflow
While supporting browsers will all prevent a form submission if it's invalid, everything outside of that is a browser design decision.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sitWolf it’s pretty clear from the video that the SweetAlert2 gets executed correctly both times (i.e. the two alerts are shown in both occasions). So why do you think the issue is with SweetAlert? Have you checked the browser console to debug the issue?
Hi @sitWolf which version of SweetAlert are you using? Clearly you are not using the latest version since the swal is now invocated using
Swal.fire()
.I tried your code (with some changes) on the latest version and I haven’t reproduced the issue. Please provide a live example using the instructions here