You didn’t return anything to UI builder. You manually change Browser DOM(changing HTML by your hands). You could return a value from these handlers, and set it to Page Data in On Click(or any else system handle). For this purpose, you could add and pass Page Data to Custom Code like below.
Sorry for the confusing request. Let’s start with something basic. How can I add this function to a On Page Enter Custom Code Block and call it on a button click?
const connectDevice = () => {
navigator.hid.requestDevice({filters:[]}).then(devices => {
if (devices.length == 0)
return;
for (let device of devices)
addDevice(device);
});
};
Is there an article about how the Custom Code block works? For example, why did you put the function connectDevice in the clock block that runs on click and not in a Custom Code block for On Page Enter?
If this were HTML I would put the function code in the head tag. Is putting code in a custom code block On Page Enter similar?