Using jQuery DataTables with Aurelia


This is assuming you have an Aurelia project set up and just want to add jQuery DataTables.

First, use jspm to grab datatables.


jspm install datatables=npm:datatables

When that’s done, you can start using it on a table in a view/viewmodel.


import $ from 'jquery';
import dataTable from 'datatables';

export class DataTableViewModel { 
  activate() {
      //bind your data here
  }
  attached() {
      $('.js-table').dataTable( {
        "paginate": true,
        "pageLength": 25
      });
  }
}

There might be a better way to do this, but this works for now. I mostly based this on this excellent post about Toastr and Aurelia