Hi!
Want to call js code from within flow.
When doing this:
getElement().executeJs("function greet(name) { console.log('hello ' + name);}; greet('Main');");
it works perfectly - I get the console log message.
However, putting the js code in a js-file and importing it with
@JavaScript(value = "frontend://script.js")
and just calling
getElement().executeJs("greet()","Main");
I get: ReferenceError) : greet is not defined
Everything is done from the MainView constructor as the only thing going on in the program.
I guess it has to do with the “scope” of the js-code, being one and the same when everything is in the same executeJs statement, but missing when trying to call it in a .js file.
I am absolutely sure that the file gets icluded, as if I call the greet() function directly from within it, I get the log when running the Vaadin program:
function greet(name) { console.log("howdy " + name); }
greet('insider');
Any help?
TIA