Problem initializing - DataTables Editor must be initialised as a 'new' instance'

Problem initializing - DataTables Editor must be initialised as a 'new' instance'

Luis EsnaolaLuis Esnaola Posts: 5Questions: 2Answers: 0
edited December 2018 in Priority support

Hello, I recently purchased the editor and we are strugling to initialize it.

Until now, I managed to work with the trial version this way:

import $ from 'jquery';
let editor = require("./dataTables.editor")(window, $);

dataEditor = new editor({
        table: '#' + targetDiv + "-table",
        fields,
        ...
    });

Since purchasing the licence, I downloaded the same file I did previously with the trial version and did:

node node_modules/datatables.net-editor/install.js pathToEditorZip
But now it shows an alert saying:

DataTables Editor must be initialised as a 'new' instance'

and the error on the console:

Uncaught TypeError: Cannot read property '_constructor' of undefined
    at Editor (dataTables.editor.js:80)

I've tried to install the trial version again and it works, no alert and no error in console.
What is different in the purchased file and how could I make it work?

Edit:
I forgot to mention that the moment the alert and error appears is at this line:
let editor = require("./dataTables.editor")(window, $);
Just saying that it doesn't even get to the line where I start the editor.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin
    Answer ✓

    It sounds like you might need to try using:

    let editor = require("./dataTables.editor");
    

    to get the constructor. I don't understand why there would be a difference between the trial and full versions though. Are they both 1.8.1 that you were using?

    Thanks,
    Allan

  • Luis EsnaolaLuis Esnaola Posts: 5Questions: 2Answers: 0

    Thank you very much Allan. Haven't tried that way but it seems to fix the problem. Yes I'm using 1.8.1 on both and I still don't understand why in the trial version I had to put (window, $).

    Thanks again,
    I'm a big fan of you, Allan.

This discussion has been closed.