Apply element enable/disable to on_click/on_change events #983
Replies: 3 comments 4 replies
-
Thanks for the proposal, @thetableman! |
Beta Was this translation helpful? Give feedback.
-
Just for reference, here is an example how one can inject a click event on a disabled button: b = ui.button('Click me', on_click=lambda: ui.label('You did it!'))
ui.switch('Enable').bind_value_to(b, 'enabled')
ui.button('Inject click', on_click=lambda: ui.run_javascript(f'getElement({b.id}).$emit("click")', respond=False)) |
Beta Was this translation helpful? Give feedback.
-
I just created PR #1030. What do you think, @thetableman? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When an element is enabled or disabled this affects the web ui only, it's fairly easy for a user to overcome this by adjusting the html using a browsers inspect tool.
Obviously it's best practice to follow up a ui disable with some back-end validation, however, it would be useful if the enable/disable affected whether a on_click or on_change fired. This could be an additional method or parameter.
For example:
or
This would reduce code to validate after a disable in simple cases and truly 'disable' an element.
Beta Was this translation helpful? Give feedback.
All reactions