Generic JavaScript View - ReferenceError: Function is not defined

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 :frowning: )
Maybe someone has an idea what I am doing wrong…

Example workflow of some of my tries:
tabulator example.knwf (264.2 KB)

E.g.:

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

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

-grafik

-$.getScript(‘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”;

js.onload = function() {

However every time I try it seems like the script is not executed or not at the right time :frowning:
When inspecting I always get the following error:
grafik

When doing it in a simple html file - it works just fine
tabulator.txt (1.5 KB)

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

Hi @AnotherFraudUser,

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

JS Library.knwf (343.5 KB)

Cheers!
Matheus

3 Likes

Hi @toscanomatheus ,

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

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.

1 Like

Great!
Thanks for the explanation :slight_smile:

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