How to include datatables responsive in ES6

How to include datatables responsive in ES6

jnajna Posts: 19Questions: 5Answers: 0

Hi
I'm looking for the alternative in ES6 import to "https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"

For example I have "import Datatables from 'datatables/media/js/jquery.dataTables';" which I use for the basic datatable init.
I have tried with "import Responsive from 'datatables.net-responsive/js';" but it does not work

Prior to all this I have run: npm install --save datatables.net-responsive-dt
So my question is: How do I invoke my datatatables.responsive node_module in my ES6 js file :-)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Answer ✓

    That should work I'd thought. Could you console.log( Responsive ); there and let me know what it is? It should be the DataTables object.

    Allan

  • jnajna Posts: 19Questions: 5Answers: 0
    edited October 2018

    Ok, My bad. I did not include the file name....
    It should be: import Responsive from 'datatables.net-responsive/js/dataTables.responsive'; and not just import Responsive from 'datatables.net-responsive/js
    But your answer led me on my way

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin

    You should actually just be able to use:

    import Responsive from 'datatables.net-responsive';
    

    The package.json file for that package uses main to point to the Responsive Javascript file.

    Allan

This discussion has been closed.