flexx icon indicating copy to clipboard operation
flexx copied to clipboard

Use flx.create_element to create a label in the for loop, bind the onclick event, and dynamically transfer parameters. lambda fun error

Open 1751660300 opened this issue 1 year ago • 0 comments

hello,i find a problem when used flx.create_element,i want to create element by this code:

def _render_dom(self): for index, data in enumerate(self.table_data): tds = [] check_id = data.get("id") index_id = flx.create_element('input', {"type": "checkbox", "id": check_id, "value": check_id, "name": "checked", "onclick": lambda e: self.checkd_fun(check_id)}, ) tds.append(index_id) return flx.create_element('div', {}, tds)

then i run this code and click input,lambda fun always trans check_id value is last data

How do I dynamically generate onclick function? Please pay attention to my question, thank you.

1751660300 avatar Mar 28 '24 08:03 1751660300