-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializing Modal through JS throws Uncaught TypeError: BACKDROP #33840
Comments
Agree with this issue. This happens in bootstrap 5.x production release irrespective of how you initialize the modal. Either dynamically via JS or via Data attributes. Currently the workaround to overcome this issue is to load the |
It happens to me too and it didn't happen in beta3. When can we expect a fix since this is (in my opinion) pretty serious? |
Hey guys. Let's take it from the beginning. Advising the Starter template and following the script loading best practices, your So the provided example is an anti-pattern, which at least could have the 'defer' attribute(which would guide to other problems) I can confirm that the default option doesn't being initialized if the scripts is loaded before body. So till be fixed, please try to load your script before |
Loading script before closing of body tag is not an option in many cases, for example in a CMS. We should not restrict the users to load the scripts in body, bootstrap should work in either way. |
I also just encountered this same issue coming from 5.0.0-beta3 and realized what was happening before finding this GH issue. Forcing users to load the Bootstrap JS file in a specific way for no good reason is not a solution. Additionally, as others have mentioned, it is sometimes not feasible or even possible to load scripts in the way being suggested. |
Guys, please calm down for a second. No one tries to enforce here something. Like @GeoSot already mentioned, adding scripts into the We adhere to the practise of putting our script tags at the end of the I understand, there are different requirements on a project and to load bootstrap in a certain way shouldn't be your concern. This is going to be addressed with the next release, but please accept, that we are all humans and errors can happen. |
The |
Modals are currently broken: twbs/bootstrap#33840
facing this issue again with bootstrap 5.10 along with Asp.net core MVC 6, when try loading modal either with pure javascript or jQuery, it throws this error again, I have tried either put script in most near |
Hey @NotAsea |
In case anyone else stumbles here, this is what solved it for me: |
Upgraded from v5 beta 3 to v5 seems to have broken dynamic modal.
When I do
I get the following error:
Please checkout the details by checking out the snippet below.
https://jsbin.com/tikogemofi/edit?html,console
This only seems to happen if I put the bootstrap JS file in
<head>
.By debugging for a bit, I was able to see that the code below
https://github.com/twbs/bootstrap/blob/main/js/src/util/backdrop.js#L14
was set to
null
.This error probably occurred because document.body does not exist yet when the JS gets loaded in
<head>
.The text was updated successfully, but these errors were encountered: