Open
Description
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.