input_action_button not triggering reactive.event

I have created an input_action_button on a tab in my shiny app and it doesn't seem to be triggering the reactive event. I declared the button on the nav tab:

ui.nav_panel('Request a Change', 
                     ui.input_action_button("submit", "Submit Request", class_="btn-primary")
        )

and then declare the response function as follows:

def server(input: Inputs, output: Outputs, session: Session):
    @reactive.event(input.submit, ignore_init=True)
    def button_click():
        print("sending...")

Even this simple functionality doesn't execute when I click the button. Am I missing something? If it's on a tab, do I need to reference it some different way?

You're missing a @reactive.effect try the below or the example at Shiny for Python

from shiny import App, render, ui, reactive

app_ui = ui.page_fluid(
           ui.input_action_button("submit", "Submit Request", class_="btn-primary")
)

def server(input, output, session):
    
    @reactive.effect
    @reactive.event(input.submit)
    def button_click():
        print("sending...")
        ui.notification_show(
            "Change request submitted successfully!",
            type="message"
        )
    
app = App(app_ui, server)

Thank you! That worked. I thought about that but I hadn't had to use that previously so I ruled it out. Guess things changed

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.