Hi!
by implementing a Paypal-Button i can use a js-script which gets the order id by JSON from Backend.
Because i am very bad in coding js, i want to do as much as possible in python.
So i tried to call reflex-function from js-code, but failed. how to do that?
"""Welcome to Reflex! This file outlines the steps to create a basic app."""
import reflex as rx
from rxconfig import config
class State(rx.State):
"""The app state."""
blah=0
changevar="changeme"
def index() -> rx.Component:
return rx.container(
rx.text("scriptcall-Test"),
rx.html(
'<div id="paypal-button-container" class="paypal-button-container"></div>'
),
rx.html(
'<p id="result-message">Result-Message-Contrainer</p>'
),
rx.script('function dosomething(message) { const container = document.querySelector("#result-message"); container.innerHTML = message; }'),
rx.button(
"Test",
# on_click=rx.call_script('dosomething("whohoo");'), #OK!
on_click=rx.call_script('reflexfunc();'), # _call_script ReferenceError: reflexfunc is not defined
),
rx.text(State.changevar)
)
def reflexfunc():
State.changevar="changed"
called=True
app = rx.App()
app.add_page(index)
```