Skip to content

How do I use IDOM to preventDefault? #356

Answered by rmorshea
Archmonger asked this question in Question
Discussion options

You must be logged in to vote

Instead of just assigning a plain function to an event like onClick you can add a decorator to the event handler that encodes extra information like prevent_default or stop_propagation.

@idom.component
def MyComponent():
    @idom.event(prevent_default=True)
    def handle_click(event):
        ...
    return idom.html.href({"onClick": handle_click}, ...)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rmorshea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants