Closed tombeteende closed 7 months ago
This has to do with the way streamlit handles state,
You could try something like this:
current_card_clicked = -1
for my_card in enumerate(my_cards):
card(**my_card, on_click=lambda: current_card_clicked = my_card["id"])
st.write(my_cards[current_card_clicked]["title"])
Does it work for you when you click the one card then the other, and then the first one back? For me it always returns the one which was clicked the last for the first time
Again, this isn't an issue related to the package, you have to find pythonic ways to make it work.
I understand it does not relate to the package. It also relates not to Python but rather to how streamlit deals with click events. Having said that, the suggested solution does not work.
I have multiple cards, roughly creating by -
Now I want to add a functionality that when I click them it writes down something, let's say the title, e.g
st.write(my_card['title'])
When adding something like -
It writes it for all the cards that were previously clicked. Is there a way to disable previous clicks / identify the last clicked card? or any other option that will allow me to control the behavior?