How can I integrate the Editor using require.

How can I integrate the Editor using require.

IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4
edited December 2016 in Free community support

I installed all the datatable packages via NPM. It looks like this

window.$ = window.jQuery = require('jquery');
var DataTable = require( 'datatables.net' );
require( 'datatables.net-bs' );
var buttons  = require( 'datatables.net-buttons' );
require( 'datatables.net-buttons-bs' );
require( 'datatables.net-buttons/js/buttons.colVis.js' );
require( 'datatables.net-buttons/js/buttons.html5.js' );
require( 'datatables.net-buttons/js/buttons.flash.js' );
require( 'datatables.net-buttons/js/buttons.print.js' );

This works great. Now I have troubles with the editor. Since it's a paid product it's not at NPM, if I include it before my main JS file I get an error that jQuery is not defined, if I include it after then I can't use the editor in my files as it's not initialized.
How can I solve this?
I tried these formats, but no luck.

require('./dataTables.editor.min.js'); //give me cannot find module "."

$.fn.dataTable.Editor = require('./dataTables.editor.min.js'); //give me cannot find module "."
window.fn.dataTable.Editor = require('./dataTables.editor.min.js'); //Cannot read property //'dataTable' of undefined


I basically have an assets/js folder where I have all the files and they are compiled using webpack.

This question has an accepted answers - jump to answer

Answers

  • IsaacBenIsaacBen Posts: 35Questions: 8Answers: 4
    edited December 2016 Answer ✓

    Never mind. I had to split my main JS file into two. That way I can just include the editor between both files.

This discussion has been closed.