Hi everyone, I had a problem when I applied dbc.themes.BOOTSTRAP.
I want to use Modal and I follow up with an example at dbc.Modal .
I copied the example code and tried to run but it isn’t working. Nothing shows up.
I watched my app log and saw: GET /assets/3-col-portfolio.css?m=1684812857.643925 HTTP/1.1" 304 GET /assets/bootstrap.css?m=1683180915.0 HTTP/1.1" 304 GET /assets/s1.css?m=1683192635.0 HTTP/1.1 304 GET /assets/style.css?m=1683192635.0 HTTP/1.1" 304
I think that is the reason make my app is not working? Is that right? and can you give me solutions to fix it
import dash
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
app.layout = dbc.Container(
[
dbc.Button("Open modal", id="open", n_clicks=0),
dbc.Modal(
[
dbc.ModalHeader(dbc.ModalTitle("Header")),
dbc.ModalBody("This is the content of the modal"),
dbc.ModalFooter(
dbc.Button(
"Close", id="close", className="ms-auto", n_clicks=0
)
),
],
id="modal",
is_open=False,
),
]
)
@app.callback(
Output("modal", "is_open"),
[Input("open", "n_clicks"), Input("close", "n_clicks")],
[State("modal", "is_open")],
)
def toggle_modal(n1, n2, is_open):
if n1 or n2:
return not is_open
return is_open
if __name__ == "__main__":
app.run_server()
Hi @AIMPED , I didn’t get errors with app.run(debug=True).
But I checked Chrome Developer Tools and I got Failed to load resource: net::ERR_FILE_NOT_FOUND dom.js:1.
I tried many different ways to apply Bootstrap (I follow up with https://dash-bootstrap-components.opensource.faculty.ai/docs/ ) but it’s still not working.
Yes, It is still the same error and I don’t have an assets folder.
When I checked more deeply with dom.js in Chrome Developer Tools, dom.js is duplicated.
One has nothing and one has some code (image below).
And by updating / installing do you first remove the existing version and reinstall again, or you just run install again (if so, it will just tell you the pre-reqs are met and nothing changes). I had this one time where it wouldn’t actually correct whatever was wrong.
I would recommend just to try to start from zero. Clean directory, clean virt env. And install the dependencies again. See if a basic dbc example works without modal, and then with it.
Wherever it fails you know at least where to look.
Hi @jcuypers ,
Thank you for your solutions. I did exactly what you said when I reinstalled or upgraded the existing library but it didn’t work.
I created a new virt env and started from zero but it still failed.
Flask 2.2.5. When I installed the latest version of Flask, I got an error: dash 2.10.2 requires Flask<2.3.0,>=1.0.4, but you have flask 2.3.0 which is incompatible.
I am using Windows 10 pro, version 22H2, os build 19045.3086