# Generic JavaScript View - ReferenceError: Function is not defined

**URL:** <https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082>\
**Category:** KNIME Analytics Platform\
**Created:** [May 25, 2020, 5:30pm UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082 "2020-05-25T17:30:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 25, 2020, 5:30pm UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/1 "2020-05-25T17:30:43Z")

</div>

Hi Community,

I have a problem regarding generic javascript views and the import of a js-file  
(I know that this seems to be asked alot - but from the previous answers I do not seem to get it to work ☹ )  
Maybe someone has an idea what I am doing wrong…

Example workflow of some of my tries:  
[tabulator example.knwf](https://forum.knime.com/uploads/short-url/h1no7Ykl7DEgeHy7pwIPpdPcXV2.knwf) (264.2 KB)

E.g.:

> [@Using external JS libraries via webTemplate folder](https://forum.knime.com/t/using-external-js-libraries-via-webtemplate-folder/23855/5):
>
> Hi Alexander, It seems that including the content of the library in the knime\_template.js did not work. Just so you know, I got an error after the login (when the main page was being loaded), which for me indicates that it has to do with the loading of the file (and not my workflow). require.js:5 Uncaught Error: Mismatched anonymous define() module: function(){return ... For reference, I am trying to use the [Mermaid JS library](https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.5.0/mermaid.min.js) Is this something we can check via the support?

-\>trying the same lib as @KnimeWorker - not sure if he got it to work or not 🤔

> [@Generic JavaScript View - include Js](https://forum.knime.com/t/generic-javascript-view-include-js/23889):
>
> Hi Everyone, I want to use a third party library combined with the generic JavaScript view: However I am not sure how to add them to the node roll_eyes Normally I would just include it through: link href=“dist/css/tabulator.min.css” rel=“stylesheet”\> script type=“text/javascript” src=“dist/js/tabulator.min.js”\> However KNIME does not seem to access the local files in the script Is there some function like the “Additional Libraries” from the java snippet node? For the CSS file I thi…

I tried to include the js file through a flow variable, though copy&paste and different getscript ways:

- ![grafik](https://forum-cdn.knime.com/uploads/default/original/3X/1/a/1a2ff850bd3a23c56d244ea9d4f5d4019863f7c4.png)

- jQuery.ajax({  
url: ‘[https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js](https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js)’,  
dataType: ‘script’,  
success: function () {

-$.getScript(‘[https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js](https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js)’, function()  
{

-var js = document.createElement(“script”);

js.type = “text/javascript”;  
js.src = “[https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js](https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.4.3/js/tabulator.min.js)”;

js.onload = function() {

However every time I try it seems like the script is not executed or not at the right time ☹  
When inspecting I always get the following error:  
 ![grafik](https://forum-cdn.knime.com/uploads/default/original/3X/0/0/003140eeeb62322653bb4741b58dc62213661cd7.png)

When doing it in a simple html file - it works just fine  
[tabulator.txt](https://forum.knime.com/uploads/short-url/y5mCMgWiOQNCoQa5T7j1Hhez04O.txt) (1.5 KB)

In general the import of js seems overly complicated with the generic javascript view 😓  
…or I am just too stupid to see what I have to do 🙈

---

<div class="post-metadata">

**Author:** ![toscanomatheus](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/7feea3/32.png) [@toscanomatheus](https://forum.knime.com/u/toscanomatheus)\
**Post date:** [May 26, 2020, 7:30am UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/2 "2020-05-26T07:30:48Z")

</div>

Hi @AnotherFraudUser,

Here is a working example for Tabulator (using the same principle as the workflow that solved my issue).

[JS Library.knwf](https://forum.knime.com/uploads/short-url/88LZrakxQKuzs5lnRRsvqWQWSlY.knwf) (343.5 KB)

Cheers!  
Matheus

---

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 26, 2020, 7:47am UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/3 "2020-05-26T07:47:10Z")

</div>

Hi @toscanomatheus ,

thank you so much! 🙂  
Just for my understanding  
var Tabulator = module.exports;  
was the important part which i missed?

---

<div class="post-metadata">

**Author:** ![toscanomatheus](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/7feea3/32.png) [@toscanomatheus](https://forum.knime.com/u/toscanomatheus)\
**Post date:** [May 26, 2020, 7:57am UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/4 "2020-05-26T07:57:46Z")

</div>

I think so. I am no specialist, but I think that when the content of the library runs (from the content of the flow variable) this _module_ and _exports_ js variables are populated. That was also what I struggled with.

---

<div class="post-metadata">

**Author:** ![AnotherFraudUser](https://forum-cdn.knime.com/user_avatar/forum.knime.com/anotherfrauduser/32/16912_2.png) [@AnotherFraudUser](https://forum.knime.com/u/AnotherFraudUser)\
**Post date:** [May 26, 2020, 10:48am UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/5 "2020-05-26T10:48:13Z")

</div>

Great!  
Thanks for the explanation 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 2, 2020, 10:48am UTC](https://forum.knime.com/t/generic-javascript-view-referenceerror-function-is-not-defined/24082/6 "2020-06-02T10:48:15Z")

</div>

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