-
-
Notifications
You must be signed in to change notification settings - Fork 328
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.
All reactions
Answered by
rmorshea
Apr 29, 2021
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
-
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}, ...)
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Answer selected by
rmorshea
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment