Callback with variable number of inputs (which are outputs of a previous callback)?

Hi everyone,
My app looks like this

I have a dataset, filtered by the inputs at the top, and the resulting values are splitted into 4 categories (corresponding to the 4 buttons on top). A click on one button triggers a callback that displays the corresponding cards, which are not here at launch, and which number will vary.

I would like these cards to be clickable, so i can generate another callback upfront. Therefore, I should write my inputs this way :
[ Input( f"{product}-card", ‘n_clicks’) for product in displayed products]
but the problem is that even if all cards have an ID, I can’t access the cards that are actually displayed without using a global variable.

Do you know how I should proceed ?

Thanks a lot

Right now about the only solution is to pre-create all the possible callbacks and elements you might ever need, and hide most of them. Not a very nice solution. But we’re actively working on a better way we’re calling “wildcard callbacks”

Thanks @alexcjohnson for the reply! After one day of racking my brain, I figured out I had to do as you say.
And as I have a lot of cards to display, I shall write a ‘create_callback’ function, am I right ?

Just out of curiosity, when do you think wildcard callbacks will be ready ? Before end of 2019?

Thanks a lot for what you are doing !

1 Like

Yes, we expect to have this ready before the end of 2019.

@alexcjohnson Hi Alex, Is this wildcard functionality ready? If yes please share the documentation.

Yep! The name changed a little, it came out last spring. Pattern-Matching Callbacks | Dash for Python Documentation | Plotly