How to get values from frontend script #466
Replies: 2 comments 4 replies
-
Hi Sergey, the architecture, due to security concerns, only allows communication from client to server via events. You can generate an event and catch it on the other side. I tested this and it works as expected. Then the event export function sendCustomEvent() {
alert("Sending");
const ev = new CustomEvent("myinfo", {
detail: {
payload: window.screen.height,
callback: () => {
alert("Custom event sent successfully.");
},
},
});
globalThis.core.forwardEvent(ev, [{componentId: "root", instanceNumber: 0}], true);
} What's the use case by the way? We may look into implementing a more straightforward way of doing this. |
Beta Was this translation helpful? Give feedback.
-
@ramedina86 export function getLocationAndShowCoordinates() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log("Latitude: " + position.coords.latitude);
console.log("Longitude: " + position.coords.longitude);
document.getElementById('coordinates').innerHTML =
"Latitude: " + position.coords.latitude + "<br>" +
"Longitude: " + position.coords.longitude;
});
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
} I now don't know how and where to catch the event. when you say root component is that src/ui/src/components/core/root Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to get the screen size from the Javascript function and use it in Python functions.
The function state.call_frontend_function returns None.
How to get values from the frontend module?
Beta Was this translation helpful? Give feedback.
All reactions