Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Modal toggle not working as desired

$
0
0

I am using a modal popup in my dash application. In the layout, I have 2 buttons defined. One
Opens the modal and other one Closes it. I referenced the example in documentation and using a slightly different code to listen to each button.

Upon close of the Modal, I’d like to call a function and run some other lines of code. However, I can’t seem to listen to the button click of close button.

            # Modal buttons - layout code

            dbc.Button("Add", id="open-btn"),
 
            dbc.Button("Close", id="close-btn")


            # Callbacks
          
             # Modal toggle
             @app.callback(Output("modal-2", "is_open"),
             [
                  Input("open-btn", "n_clicks"),
                  Input("close-btn", "n_clicks")
             ],

             [
                  
                  State("Address", "value"),
                  State("City","value"),
                  State("Zip","value"),
                  State("State","value"),
                  State("modal-2", "is_open")
             ],
             )
            def add_prop(open_btn, close_btn, address, city, zip, state, is_open):

                 if open_btn:

                    return not is_open

                ## This code doesn't work 

                if close_btn:

                   print("Call function")
        
                   append_prop(tenant, industry, address, city, zip, state)

                   return is_open


I am trying to figure why the close pop up block of code isn’t work.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles