I’m quite confused and hoping I’m just missing something obvious. I seem to be unable to access my JS functions specified in module.js from module.html. Console reports that the function is undefined.
From what I’m seeing there is no relation between the module html and js file, which makes me wonder why it’s even there in the first place. If a js file is created with your module, then shouldn’t it be included and accessible? This seems crazy to me. I’d assume the whole reason this is setup as such is to provide convience and scoping for the local module instance, but that doens’t seem to be the case.
I know we can add an event listeners for click to trigger the function, but that is not helpful at all when you need to pass data to the function. Please tell me I’m missing something obvious.
A simple example of my use case is:
- I have 3 instances of the module I created, each with a different logo, description, and webiste url
- When a user clicks on 1 of the 3 instances I pop up a message displaying additional info as well as the information listed above
If I have to rely on event listeners, then querying for the particulat instance is a massive pain, and passing a bunch of data about that specific instance is also an indirect pain, espiecally when the following seems like it shoudl be feasible:
// module.html
<button class="button hs-button" onclick="onClick('{{module.company_logo}}', '{{module.nhd_company_name}}')">
{{module.button_text}}
</button>
// module.js
function onClick(logo, name) {
console.log('--------- do some things');
}