Looking for some assistance here, I believe I might be missing a small detail.
The _layout.cshtml
file includes all the necessary scripts to ensure that sweetheart works on IE:
(this used to work in previous versions, but we haven't had to support IE for a while)
@if (Request.Browser.Browser == "IE" || Request.Browser.Browser == "InternetExplorer")
{
<script src="https://npmcdn.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94f1e7a2b9e4e6fbf9fde7f1d4a7baa6baa5">[email protected]</a>"></script>
}
<script type="text/javascript" src="~/bower_components/sweetalert2/dist/sweetalert2.min.js"></script>
<!--[if IE 9]>
<script src="~/bower_components/sweetalert2-ie9/dist/sweetalert2.min.js"></script>
<![endif]-->
As you can observe, the promise is included before sweetalert2
and I know this setup is correct because sweetalert functions when my form is submitted.
The problem arises when I click "Yes," the .then()
function doesn't get executed. In the debugger, it seems to be skipped over and ignored. This issue is specific to IE and has only been tested in version 11 so far. I'm currently checking other versions to determine the cause. Any thoughts on why this might be happening?
Here's the relevant .js code snippet:
vm.PostCommentData = function (postData, event) {
var $commentTextBoxId = '#' + vm.createRemedyCommentId;
if ($($commentTextBoxId).length) {
var globalTranslations = globalDashboard.GetTranslations();
swal({
title: translations.AreYouSureYouWantToSubmit,
text: '',
type: 'warning',
showCancelButton: true,
confirmButtonText: '<i class="fas fa-thumbs-up"></i> ' + globalTranslations.Yes,
cancelButtonText: '<i class="fas fa-thumbs-down"></i> ' + globalTranslations.No,
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',
buttonsStyling: false
}).then(function () {
vm.state($(event.currentTarget).data('state'));
var newComment = $($commentTextBoxId).val();
var errorMessage = $("<ul class='list-unstyled' />");
var hasErrored = false;
if (vm.selectedQuestions().length == 0) {
errorMessage.append("<li>" + translations.AtLeastAQuestionIsRequiredToBeSelected + "</li>");
hasErrored = true;
}
if (vm.selectedDealershipId() == undefined) {
errorMessage.append("<li>" + translations.PleaseSelectADealership + "</li>");
hasErrored = true;
}
if (newComment === '') {
errorMessage.append("<li>" + translations.CommentTextIsRequired + "</li>");
hasErrored = true;
}
if (hasErrored) {
swal({
title: translations.Warning,
html: errorMessage,
type: 'error',
buttonsStyling: false,
confirmButtonText: '<i class="fas fa-check"></i> ' + globalTranslations.OK,
confirmButtonClass: 'btn btn-success'
});
}
else {
var successMessage = translations.YourRemedyHasBeenSubmitted;
if (vm.selectedQuestions().length > 1)
successMessage = translations.YourRemediesHaveBeenSubmitted;
swal({
title: translations.Completed,
text: vm.globalViewModel().decodeEntities(successMessage),
type: 'success',
buttonsStyling: false,
confirmButtonText: '<i class="fas fa-check"></i> ' + globalTranslations.OK,
confirmButtonClass: 'btn btn-success'
}).then(function () {
$(remedyBoxId + " .overlay").show();
$('#create-remedy-commentFormId').submit();
});
}
});
}
}
vm.
references knockout.js
, but I am fairly certain that knockout is not involved in this issue.