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 - <button class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg">Large modal2</button> <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...
Author   hongbo-miao
Discussions

Missing modal static backdrop animation
Describe the bug There's an animation missing from a modal with static backdrop when trying to click on the backdrop or by pressing escape when keyboard is set to false. See Bootstrap docs for ... More on github.com
🌐 github.com
3
May 5, 2020
data-backdrop is not working on livewire.
Hello! I try to prevent the modal to close when click outside the modal. It's working on my one project but in my new setup it doesn't working.. Does the livewire component has a conflict o... More on github.com
🌐 github.com
1
1
data-bs-backdrop and data-bs-keyboard not functioning on v5.0.1
Trying to use the data-bs-backdrop="static" and data-bs-backdrop="false" to manipulate how the modal backdrop is working. It worked on the 5.0.0-beta2 version. However, it does ... More on github.com
🌐 github.com
8
May 21, 2021
TypeError Cannot read properties of undefined (reading 'backdrop') - bootstrap v5.2.1 modal
While using bootstrap modal I am facing this error ( TypeError Cannot read properties of undefined (reading 'backdrop') ) , which is tracked by our bug tracker, but I am unable to recreate this err... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › react-bootstrap › react-bootstrap › issues › 5163
Missing modal static backdrop animation · Issue #5163 · react-bootstrap/react-bootstrap
May 5, 2020 - Describe the bug There's an animation missing from a modal with static backdrop when trying to click on the backdrop or by pressing escape when keyboard is set to false. See Bootstrap docs for ...
Author   kyletsang
🌐
GitHub
github.com › twbs › bootstrap › issues › 34069
data-bs-backdrop and data-bs-keyboard not functioning on v5.0.1 · Issue #34069 · twbs/bootstrap
May 21, 2021 - Trying to use the data-bs-backdrop="static" and data-bs-backdrop="false" to manipulate how the modal backdrop is working. It worked on the 5.0.0-beta2 version. However, it does ...
Published   May 21, 2021
Author   javierian1313
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal backdrop: static not allowing clicks without closing t - Material Design for Bootstrap
@Nate To achieve this kind of functionality, you can use the cookie modal and set the ignoreBackdropClick to false. https://mdbootstrap.com/docs/angular/modals/additional/#modalCookiesSec ...
Find elsewhere
🌐
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
🌐
CopyProgramming
copyprogramming.com › howto › javascript-data-backdrop-static-data-keyboard-false
Disabling Keyboard and Backdrop for Static Data in Javascript - Javascript
April 21, 2023 - To open the modal using JavaScript, utilize '$("#myModal").modal({backdrop: "static", keyboard: false})'. For those using data attributes, a different method can be employed.
🌐
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
🌐
GitHub
github.com › twbs › bootstrap › issues › 37305
TypeError Cannot read properties of undefined (reading 'backdrop') - bootstrap v5.2.1 modal · Issue #37305 · twbs/bootstrap
October 12, 2022 - modal1 = new bootstrap.Modal(document.getElementById('modal1'), { backdrop: "static", keyboard: false }); modal2 = new bootstrap.Modal(document.getElementById('modal2'), { backdrop: "static", keyboard: false }); modal3 = new bootstrap.Modal(document.getElementById('modal3'), { backdrop: "static", keyboard: false }); Reactions are currently unavailable ·
Author   rohith2810
🌐
Bootstrap
getbootstrap.com › docs › 5.0 › components › modal
Modal · Bootstrap v5.0
For data attributes, append the option name to data-bs-, as in data-bs-backdrop="". All API methods are asynchronous and start a transition. They return to the caller as soon as the transition is started but before it ends. In addition, a method call on a transitioning component will be ignored. See our JavaScript documentation for more information. Activates your content as a modal. Accepts an optional options object. var myModal = new bootstrap.Modal(document.getElementById('myModal'), { keyboard: false })
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal Keyboard Issue and solution - Material Design for Bootstrap
public setConfiguration(config) { this._config = { backdrop: config.backdrop || true, keyboard: config.keyboard || true, focus: true, show: config.show || true, ignoreBackdropClick: false }; } problem is the keyboard JUST NEVER WORKS so i had to change the OnEsc method to the following · // todo: consider preventing default and stopping propagation @HostListener('keydown.esc') public onEsc(): void { if (this.config.backdrop !== 'static') { this.hide(); } } I do not like this hack, but it seems to be the only solution.
🌐
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" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Glass Animals</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> Glass Animals are an English indie rock band from Oxford consisting of members Dave Bayley (lead vocals, guitar), Drew MacFarlane (guitar, keys, backing vocals), Edmund Irwin-Singer (bass, keys, backing vocals), and Joe Seaward (drums).
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal backdrop is not working - Material Design for Bootstrap
For example user clicked on the Recommended Questions button and opened a modal with backdrop=false, but when try to click on the button again it's not allowing to click on that button. Please check the below image for reference. ... Please let me know for any clarifications on the same. ... The solution is simple. For my modal, I added wrapClassName property with my class backdropFix and for my css file I add this code: ... And now I can click for example the button in background of the modal. ... import React, { Component } from 'react'; import { MDBContainer, MDBBtn, MDBModal, MDBModalBody,
🌐
Stack Overflow
stackoverflow.com › questions › 64502261 › block-modal-with-data-backdrop-and-data-keyboard-on-runtime
Block modal with "data-backdrop" and "data-keyboard" on runtime?
October 23, 2020 - $('#cadastroModal').data('bs.modal')._config.backdrop = 'static'; $('#cadastroModal').data('bs.modal')._config.keyboard = false;