How do I use IDOM to preventDefault? #356
Answered
by
rmorshea
Archmonger
asked this question in
Question
-
Does IDOM override href's click events to intercept URL routing, or will I need to manually implement this for SPA purposes? If so, is it a generic selection across all href elements, or only on href components directly rendered by IDOM? |
Beta Was this translation helpful? Give feedback.
Answered by
rmorshea
Apr 29, 2021
Replies: 1 comment
-
Instead of just assigning a plain function to an event like @idom.component
def MyComponent():
@idom.event(prevent_default=True)
def handle_click(event):
...
return idom.html.href({"onClick": handle_click}, ...) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rmorshea
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 likeprevent_default
orstop_propagation
.