Skip to content

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

Closed

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

Activity

  1. changed the title [-]Support executing javascript within events by declaring them as string type[/-] [+]Support for string events (to execute raw javascript)[/+] on Jan 28, 2025
  2. linked a pull request that will close this issueSupport raw JavaScript events #1289on Mar 29, 2025
  3. Archmonger commented on Sep 3, 2025

    @Archmonger
    ContributorAuthor

    Fixed in #1290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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