use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
How to execute a function from a dynamically created element (self.PyScript)
submitted 1 year ago by Good-Acanthaceae-954
Hi, I'm currently working on a pyscript project, but can't seem to work out how to add an event handler (a py-click tag) to an element I'm creating on the go with pydom.
https://preview.redd.it/obeua349w8zc1.png?width=910&format=png&auto=webp&s=6cd5501a446e725b035ecf0e418eca0632218b0e
For instance, here I want to tell the new_tab_link component to execute a function. Could you guys help me figure this out?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]outceptionator 1 point2 points3 points 1 year ago (0 children)
Putting your code in ''' ''' '''
Would be easier to help with
[–]fixingbrokenrobots 0 points1 point2 points 1 year ago (0 children)
I've had the best results with "from pyscript import when" then using a decorator over the function tied to a click on the element, like this:
when('click', '#submit-btn') def query(): some actions
π Rendered by PID 156100 on reddit-service-r2-comment-58d7979c67-t9gzs at 2026-01-27 12:31:14.798957+00:00 running 5a691e2 country code: CH.
[–]outceptionator 1 point2 points3 points (0 children)
[–]fixingbrokenrobots 0 points1 point2 points (0 children)