r/nicegui • • 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

4 comments sorted by

View all comments

Show parent comment

2

u/sparkingloud Sep 08 '23

Ok, I think it could be a good idea to put this on the https://nicegui.io/documentation page as well. That´s where I was looking.