JQuery DataTable not working on Meteor

I am trying to implement jQuery DataTables in my Meteor project, but I always get the following error. Can someone please tell me what I am not seeing / doing wrong here? Below is my Meteor app code. Thank.

Uncaught TypeError: Cannot set property 'pagesData' of undefined underscore.js:848
Error: Exception from Tracker recompute function:
Error: Can't call non-function: undefined
    at Spacebars.call (http://localhost:3000/packages/spacebars.js?cb20740019f26bdca2faa89ba9c973f618118521:172:13)
    at Spacebars.mustacheImpl (http://localhost:3000/packages/spacebars.js?cb20740019f26bdca2faa89ba9c973f618118521:106:25)
    at Object.Spacebars.mustache (http://localhost:3000/packages/spacebars.js?cb20740019f26bdca2faa89ba9c973f618118521:110:39)
    at null._render (http://localhost:3000/packages/jquery-datatables.js?bf10e73db3f8b2f4afdc77c33ba3c62092556ae7:1010:22)
    at doRender (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
    at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
    at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
    at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
    at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
    at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)

      

Project.html - client folder

<template name="projectslist">
  <div class="projectslist">

    <div>
        {{> DataTable dtProjects }}
    </div>

  </div>
</template>

      

Projectlist.js - client folder

Template.projectslist.dtProjects =  function() {    
  return {
    id: "my-unique-table-id",
    columns: [
      {
        title: "Name",
        data: "name"
      }, {
        title: "Description",
        data: "description"
      }, {
        title: "Delivery Date",
        data: "deliverydate"
      }
    ],
    subscription: "dtProjects",
    query: {
      grade: "A"
    }
  };
};

      

Server.js - Server folder

var ProjectsTable;
  ProjectsTable = new DataTableComponent({
    subscription: "dtProjects",
    collection: Projects
  });
  ProjectsTable.publish();

      

Projects.js - available for both server and client:

Projects = new Mongo.Collection('projects');

      

+2


source to share


2 answers


According to meteor-talk , jQuery dataTables duplicates many of the sorting and DOM manipulation features that MiniMongo, Spark, and Spacebars provide. Thus, even if you can sort the style (or choose to ignore the style), sorting and other functionality does not work as expected when the table is actively updated under the data tables.

Having said that, on July 30, 2014 Austin Rivas, creator of meteor-jquery-datatables (who is actually the creator of menway: jquery-datatables , which was created to create the Meteor Datatable package) mentioned in the Meteor Google support groups:

There is a lot of difficulty using jquery-datatables and meteor interaction to duplicate functionality and reconcile the state of the jquery-datatables dom with meteor reactivity.

So it would be nice to check out another package, or perhaps check out alternative pagination approaches: https://github.com/awatson1978/clinical-ui-crud-table



Personally, I would recommend Reactive Table https://github.com/ecohealthalliance/reactive-table . It's pretty stable, easy to implement / customize.

See also:

+4


source


  • Remove version mrt

    :

    mrt remove jquery-datatables

  • Add version Meteor 0.9+

    :

    meteor add menway:jquery-datatables

However, it looks like it is still not 0.9 compliant as package.js still uses spaces. Give it a chance.



It might be worth looking at this extension: https://atmospherejs.com/ephemer/reactive-datatables

+1


source







All Articles