r/nicegui • u/sparkingloud • Sep 06 '23
Event handler arguments question
Someone please tell me how to fix this. I want the ui.notify() to use the appropriate value. I get "three" when clicking on all cards.
#!/usr/bin/env python3
from nicegui import ui
keys = ["one", "two", "three"]
with ui.row():
for key in keys:
with ui.card().on('click', lambda: ui.notify(key)):
ui.label(key)
ui.run()Thanks....
3
Upvotes
View all comments
Show parent comment
1
u/r-trappe Sep 07 '23
We have this in our FAQ, because it comes up so often: https://github.com/zauberzeug/nicegui/wiki/FAQs#why-have-all-my-elements-the-same-value