Skip to content

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

@Archmonger

Description

@Archmonger

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-2-moderateShould be resolved on a reasonable timeline.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions