As bootstrap only support one Modal
show as the same time. This snippets will help with close the old one.
(function () {
let deferredModal = null;
$(document.body).on('show.bs.modal', '.modal', function (e) {
let $modal = $('.modal.show').not(this);
if ($modal.length > 0) {
e.preventDefault();
e.stopPropagation();
deferredModal = this;
$modal.modal('hide');
}
})
.on('hidden.bs.modal', '.modal', function(){
if (!deferredModal) {
return;
}
$(deferredModal).modal('dispose').modal('show');
deferredModal = null;
});
})();