0

I am very new to node.js and developing a web-application, bundled with parcel, where a function has to be called by pressing a button inside a pop-up window. This popup-window is not available before another button is clicked (which opens the pop-up).

The folder for npm bundling contains the following files:

index.html, main.js, package.json and style.css (of course also the folders "dist", ".parcel-cache" and ".node_modules"

For other buttons, which are directly available on the webpage (not inside a pop-up), I tried this solution, which works fine (inside the main.js-file):

const button = document.getElementById('select_feature'); //'select_feature' is the button id in index.html
    button.addEventListener('click', function(e) {
        document.getElementById("select_feature").style.backgroundColor = 'coral';
        document.getElementById("create_feature").style.backgroundColor = '';
        document.getElementById("get_info").style.backgroundColor = '';
        map.un('singleclick', getinfo);
        overlay.setPosition(undefined);
        closer.blur();

        if (draw_add) {
            map.removeInteraction(draw_add);
        }
    
        map.on('click', highlight);
});

When I try the same way as above for functions inside the pop-up, I get this message:

Uncaught TypeError: buttonsavecreated is null.

I found this How to execute HTML-Events with NodeJS? entry, and I understand the difference between client side and server side. But I don't know how to apply this 'express.js' coding snippets working for me.

How can I execute a function for these types of buttons?

Chris_98
  • 1
  • 1

0 Answers0