I found a workaround for this issue.

Once the modal has been hidden bootstrap data still remains on it. To prevent that I had the following:

$('#myModal').modal('show'); //display something
//...

// if you don't want to lose the reference to previous backdrop
$('#myModal').modal('hide'); 
$('#myModal').data('bs.modal',null); // this clears the BS modal data
//...

// now works as you would expect
$('#myModal').modal({backdrop:'static', keyboard:false});
Answer from Daniele Piccioni on Stack Overflow
🌐
GitHub
github.com › valor-software › ngx-bootstrap › issues › 568
bug(modal): data-backdrop="static", data-keyboard="false" not work · Issue #568 · valor-software/ngx-bootstrap
June 2, 2016 - In Bootstrap 4, we can disable click outside of bootstrap model area to close modal by adding data-backdrop="static". And data-keyboard="false" to prevent close on ESC button. Like this:
Author   hongbo-miao
🌐
W3Schools
w3schools.com › bootstrap › › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
Top answer
1 of 1
2

data-backdrop is used to Specify static for a backdrop, if you don’t want the modal to be closed when the user clicks outside of the modal. and backdrop Specifies whether the modal should have a dark overlay:

  • true - dark overlay
  • false - no overlay (transparent)

If you specify the value "static", it is not possible to close the modal when clicking outside of it

put this script inside your code, pass your modal id into it

$('#myModal').modal({
          backdrop: false
        });

Here is the snippet

$(document).ready(function(){
    $("#myBtn").click(function(){
        $("#myModal").modal({backdrop: true});
    });
    $("#myBtn2").click(function(){
        $("#myModal2").modal({backdrop: false});
    });
    $("#myBtn3").click(function(){
        $("#myModal3").modal({backdrop: "static"});
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <h2>Modal Options</h2>
  <p>The backdrop option specifies whether the modal should have a dark overlay (the background color of the current page) or not.</p>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-md" id="myBtn">Modal with Overlay (backdrop:true)</button>
  <button type="button" class="btn btn-info btn-md" id="myBtn2">Modal without Overlay (backdrop:false)</button>
  <button type="button" class="btn btn-info btn-md" id="myBtn3">Modal with backdrop:"static"</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal with Dark Overlay</h4>
        </div>
        <div class="modal-body">
          <p>This modal has a dark overlay.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
  <!-- Modal -->
  <div class="modal fade" id="myModal2" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Modal without Overlay</h4>
        </div>
        <div class="modal-body">
          <p>This modal has no overlay.</p>
          <p><strong>Note:</strong> You cannot click outside of this modal to close it.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
  
  <!-- Modal -->
  <div class="modal fade" id="myModal3" role="dialog">
    <div class="modal-dialog">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Static Backdrop</h4>
        </div>
        <div class="modal-body">
          <p>You cannot click outside of this modal to close it.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
  </div>
</div>

🌐
CodePen
codepen.io › cristinaconacel › pen › ZmxgYm
Bootstrap 4 Basic Modal with Static Backdrop
<div class="container"> <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#glassAnimals" data-backdrop="static"> Glass Animals Info </button> </div> <div class="modal fade" id="glassAnimals" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" ...
🌐
Bootstrap
getbootstrap.com › docs › 4.4 › components › modal
Modal · Bootstrap
Launch static backdrop modal · <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#staticBackdrop"> Launch static backdrop modal </button> <!-- Modal --> <div class="modal fade" id="staticBackdrop" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> ...
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › components › modal
Modal · Bootstrap v5.0
Launch static backdrop modal · <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop"> Launch static backdrop modal </button> <!-- Modal --> <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> ...
Find elsewhere
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal backdrop: static not allowing clicks without closing t - Material Design for Bootstrap
The tittle says it all. Regarding documentation https://mdbootstrap.com/angular/advanced/modals/#options Type: boolean | "static" Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click.
🌐
Bootstrap Shuffle
bootstrapshuffle.com › classes › modals › modal-static
modal-static - Bootstrap CSS class
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop"> Launch static backdrop modal </button> <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> Lorem ipsum dolor sit amet consectetur adipisicing elit.
🌐
GeeksforGeeks
geeksforgeeks.org › bootstrap-5-modal-static-backdrop
Bootstrap 5 Modal Static backdrop | GeeksforGeeks
November 30, 2022 - Although, we can create the modal using Modal components classes. ... data-bs-backdrop: This attribute can be used to set the value as static, which will prevent the modal to be closed while clicking outside of it.
🌐
Tutorial Republic
tutorialrepublic.com › codelab.php
Live Demo: Bootstrap Modal with Static Backdrop
View the live example as well as try and test it using the online HTML editor.
🌐
JSFiddle
jsfiddle.net › Richard_Liu › nn093m84
Bootstrap Modal Backdrop Static. - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
🌐
GitHub
github.com › twbs › bootstrap › issues › 30647
Bootstrap v4.4.1 Modal with data-backdrop="static" data-keyboard="false" blinks on outside click. · Issue #30647 · twbs/bootstrap
April 25, 2020 - From version 4.4.0, modal with data-backdrop="static" data-keyboard="false" blinks on outside click. If the page has a scroll or the modal is vertically centered then the scroll...
Author   TanvirArjel
🌐
MDBootstrap
mdbootstrap.com › standard › modal backdrop
Bootstrap Modal Backdrop - free examples & tutorial
If you would like to prevent the modal from closing on a click outside of the modal boundries, you can set the data-mdb-backdrop attribute to static.
🌐
Lightrun
lightrun.com › answers › valor-software-ngx-bootstrap-bugmodal-data-backdropstatic-data-keyboardfalse-not-work
bug(modal): data-backdrop="static", data-keyboard="false" not work
In Bootstrap 4, we can disable click outside of bootstrap model area to close modal by adding data-backdrop="static". And data-keyboard="false" to prevent ...
🌐
Keen Themes
devs.keenthemes.com › question › backdrop-modal-static-and-keyboard-false-vue
Backdrop Modal Static And Keyboard False - Vue - Keenthemes
I want the modal has the following options: backdrop: 'static', keyboard: false How to manage this? I want a modal which is not able to close at at by clicking outside the modal, nor by keyboard. N. 3 years ago ... Hi, You can set those properties with the following attributes. ... data-bs-backdrop="static" data-bs-keyboard="false" Refer to bootstrap 5 official documentation: Regards, Lauris Stepanovs, Keenthemes Support Team