Prevent callback calls before user finish trying

I have an input box:

dcc.Input(
type=“text”,
id=“srch_for_input”,
placeholder=“Type something”,
)

and a search button:

dbc.Button(“Search”, id =“search_btn”, className=“me-md-2”)

and a simple callback where Input is as follows:
[
Input(“search_btn”, “n_clicks”),
Input(“srch_for_input”, “value”),
],

the callback function is calling an API.

When I type a letter, but before I finish the entire word, the callback is called. It is called for every letter I type. I knows how to trap this in JS and JQuery … but I am stumped here. Please advice how to prevent repeated call until I click the search button. I need to pass the content of the srch_for_input to the callback function, and this is why I have it as an Input. is there a way to pass this value to the function without listing it as a callback input?

Thanks you

Hi,

Instead of using Input for the input component, use State. Then the callback is triggered only when the button is clicked, but not when the value in the input changes.

Hello. Thank you for the quick reply. I tried State as my first attempt (and it was my first use), but I kept getting errors.

But I think I see where my mistake is, I was specifying an Input and State for the same Id in the call back. Looking here: https://dash.plotly.com/basic-callbacks

I may be able to resolve.

Thanks