Skip to content

Instantly share code, notes, and snippets.

@marcstober
Forked from jrunestone/jquery-datatables-webpack
Last active October 9, 2020 07:35
Show Gist options
  • Save marcstober/c34bb4bdf7ef622cb24d6675723749bd to your computer and use it in GitHub Desktop.
Save marcstober/c34bb4bdf7ef622cb24d6675723749bd to your computer and use it in GitHub Desktop.
DataTables.net with webpack
Here's how to make jQuery DataTables work with npm and webpack. This is the simplest way I found to do it.
See the previous revision of this gist for a way to do it with forcing AMD to be disabled if you need that.
Install DT core: npm install datatables.net
Install a DT style: npm install datatables.net-dt
Then to initialize DT in your app, do this in your main entry point:
// you can use import or require
import dt from 'datatables.net';
import 'datatables.net-dt/css/jquery.datatables.css';
Now you can use .DataTable():
$('table[data-table]').DataTable(); // or whatever you want
@solid-ahlholm
Copy link

Thank you Marcstober, and also Valsdav for pointing out the thing with uppercase T in dataTable.

@therajumandapati
Copy link

Thank you Marcstober, and also Valsdav for pointing out the thing with uppercase T in dataTable.

Saved the day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment