How to reference state within a single render UI function ? #2939
Closed
yellowbean
announced in
Q&A
Replies: 2 comments 3 replies
-
There are a few ways to go about it; if you're fine with the user entering a comma separated list, then you can define an event handler for def update_recipe_values(self, recipe_path, value):
for recipe in self.listOfRecipes:
if recipe.path == recipe_path:
recipe.val = [v.strip() for v in value.split(",")] then have your event handler do the reverse rx.input(value=x.val.join(","), on_change=lambda v: State.update_recipe_values(x.path, v)) |
Beta Was this translation helpful? Give feedback.
3 replies
-
Thanks to @masenf foreach can be nested with index, here is my code that works
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The State would have a list of recipes, which I can use
rx.foreach
to render them all into the UI .While, I would like user to edit the recipes and with
on_change
event to update the recipes in the UI, but how to implement that in theRecipesUI
function ?is there syntax that points to the item to be updated ?
State.set_listOfRecipes_<N>_val
, which points to the "State.ListOfRecipes" and the Nth item, with field name "val" ?Great work , thank you all for the help !
Beta Was this translation helpful? Give feedback.
All reactions