Performing onclick on DOM-elements in coded components

I have an HTML-file with some buttons and a script that performs on-click actions.

When I try to load the coded component I get the following error:

After some researching I believe it is because I am trying to access DOM-elements that are not loaded, so I tried to wrap my script in document.addEventListener('DOMContentLoaded', function () { ... });. What happens then is that the app loads, but it does not show any content.

When I run the code in VSCode using one HTML-file it runs fine. So, I guess there is something about the composition and connections between HTML, script and resources in Appfarm. Here is my setup:

Anyone knows what is going on? Thanks :slight_smile:

Hi, thanks for reaching out.

Can you please provide some more details of your setup?
E.g. screenshots of your code etc.

Thanks,
Erik