Strict Mode and @JsModule annotation

Hi. I am trying to use the @JsModule annotation and get a test function up and running with javascript. But as far as I understand it it always fails because of strict mode used by this annotation. The error message is Uncaught ReferenceError. Any tips on this?

ok i have this annotation on a custom component … @JsModule(“/src/components/whatever.js”)

and i have a click listener: UI.getCurrent().getPage().executeJs(“test()”);

still the test method isnt triggered

Where is the js file placed in the project? Under the fronted directory?
At least the path on the jsmodule annotation should not be absolute. Try with ./src/xyx

The path is ok I tested it. It’s in frontend folder

Did you register the test method to your window?

How do I do this? I have a declare function test… In the js file. And it is called via my executejs method

I am quite inexperienced in js. Only want to get one script running. Trying to understand the schema… I have a function. A js file and I try to execute it.

window.test = function () {
// Stuff

executeJs(“window.test();”) should be able to call this anytime

Ok i will try that.

Thank you

didnt work either.

Does it fail silently? Does it give an error message?

Uncaught ReferenceError: test is not defined




and the js file: