Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for string events (to execute raw javascript) #1261

Open
Archmonger opened this issue Jan 28, 2025 · 0 comments
Open

Support for string events (to execute raw javascript) #1261

Archmonger opened this issue Jan 28, 2025 · 0 comments
Labels
priority-2-moderate Should be resolved on a reasonable timeline.

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Jan 28, 2025

Current Situation

There's currently no existing capabilities for running a JS script from within an event tag.

Additionally, string based events serialized from html_to_vdom currently do not execute at all.

Proposed Actions

Allow events to be declared as string type. If the event is a string, pass it directly into React's prop dictionary, which will allow it to execute as traditional javascript.

@component
def my_component():
    return html.button(
        { "onClick": "$('.sidebar').toggle()" },
        "This is a button!",
    )

In this scenario, providing a str within onClick would execute the event string the client side.

Originally posted by @Archmonger in #783

@Archmonger Archmonger changed the title Support executing javascript within events by declaring them as string type Support for string events (to execute raw javascript) Jan 28, 2025
@Archmonger Archmonger added type-feature priority-2-moderate Should be resolved on a reasonable timeline. labels Jan 28, 2025
@Archmonger Archmonger linked a pull request Mar 29, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-2-moderate Should be resolved on a reasonable timeline.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant