Generic Javascript view: Uncaught Reference Error with local function

Hi,
I want to build a Javascript App (with the Generic Javascript View Node) which has a button. Clicking on the button executes a locally defined function (It doesn’t matter what the function does):

Here is a simple Example:

var body = document.getElementsByTagName('body')[0];
body.innerHTML = `
<script>function knimeTest() {
    alert("Hello");
}
</script>
<button onclick="knimeTest()">Test</button>
`;

JS_function.knwf (5.6 KB)

When trying to execute the Generic Javascript Node, I am seeing the button, but when clicking on it, I get the error, that the function is not defined ERROR CEFWizardNodeView Uncaught ReferenceError: knimeTest is not defined.

Can someone help me to figure out, how to declare a simple function and use it inside the Generic Javascript View Node?

Hello @KNIME_uzer ,

This thread explains the workaround to your code. Does this helps?

Thank you

BR,
Ali

1 Like

Thank you so much, I didn’t find that one!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.