Skip to content

use_script hook #894

Open
Open
@Archmonger

Description

@Archmonger

Current Situation

Currently, there is no method to transmit the results of a JavaScript function to the backend.

Proposed Actions

Create a use_script hook that operates similarly to html.script, but can return a result.

For example,

@component
def example():
    script = use_script("getComputedStyle(document.querySelector('#element'))")
    return f"CSS Style Attributes: {script.data}"

Since this hook operates asynchronously, the interface should pretty much match our Django use_query hook.

See this comment for traceability.

As a note, it's going to be very important for us to pre-populated the this element with the current DOM node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-3-lowMay be resolved one any timeline.type-investigationAbout research and gathering information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions