Ok, I solved it. This may not be the best solution, but it works for my special case.
I added $('#myModal').off('click'); right after i show spinner loading on submit. This prevents the modal mouse click from closing.
There was a problem disabling the escape button because browsers stop loading the page when the user clicks this button. So I decided to hide the counter in order to unlock the form using this code:
$(document).on('keydown',function(e) { if (e.keyCode == 27) { $('#myLoadingSpinner').hide(); } });
Edit: I found another solution for the background:
$('#myModal').data('bs.modal').options.backdrop = 'static';
I tried this also for keyboard = false , but it does not work.
source share