Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button in Dash doesn't have "click" as an event

I added a button to my layout. When I try to write a callback for it, I get the following error:

dash.exceptions.NonExistantEventException: 
Attempting to assign a callback with
the event "click" but the component
"get_custom_vndr" doesn't have "click" as an event.

Here is a list of the available events in "get_custom_vndr":
[]

Here's how I'm adding it to my layout:

app_vndr.layout = html.Div([
    html.Button(
        '+',
        id='get_custom_vndr',
        type='submit'
    )
])

and here's the callback function that's giving the above error:

@app_vndr.callback(
    dash.dependencies.Output('overlay', 'className'),
    events=[dash.dependencies.Event('get_custom_vndr', 'click'),
            dash.dependencies.Event('add_vndr_id_submit', 'click')])
def show_input(b1_n, b2_n):    
    if b1_n>0:
        return ''
    elif b1_n>0:
        return 'hidden'

Did I miss something when I added the button to my layout? or when I tried to write the callback?

I got it working for

dash.dependencies.Input('get_custom_vndr', 'n_clicks')

but I'd like to use two buttons for the same output and with the n_clicks event, I'd need to try to figure out which button was clicked by comparing the current n_clicks to the previous n_clicks for each button, which seems like a pretty hacky way to do it.

like image 432
RagingRoosevelt Avatar asked Nov 17 '25 11:11

RagingRoosevelt


1 Answers

Dash doens't allow multiple callback for the same Output()

like image 65
cannatag Avatar answered Nov 19 '25 02:11

cannatag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!