JQuery DataTable不能在Meteor上工作 [英] JQuery DataTable not working on Meteor

查看:203
本文介绍了JQuery DataTable不能在Meteor上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的Meteor项目中实施 jQuery DataTables ,但我总是得到以下错误。有人可以告诉我我在这里失踪/做错了吗?以下是我的Meteor应用程序代码。谢谢。

 未捕获TypeError:无法设置undefined下划线的属性pagesData:848 
错误:追踪器重新计算功能:
错误:无法调用非功能:未定义
在Spacebars.call(http:// localhost:3000 / packages / spacebars.js?cb20740019f26bdca2faa89ba9c973f618118521:172:13)
在Spacebars.mustacheImpl(http:// localhost:3000 / packages / spacebars.js?cb20740019f26bdca2faa89ba9c973f618118521:106:25)
在Object.Spacebars.mustache(http:// localhost:3000 / packages / spacebars。 js?cb20740019f26bdca2faa89ba9c973f618118521:110:39)
在null._render(http:// localhost:3000 / packages / jquery-datatables.js?bf10e73db3f8b2f4afdc77c33ba3c62092556ae7:1010:22)
在doRender(http:// localhost:3000 / packages / blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
在http:// localhost:3000 / packages / blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
在Object.Blaze._withCurrentView (http:// l ocalhost:3000 / packages / blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun(http:// localhost:3000 / packages / blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker。 (http:// localhost:3000 / packages / tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
在新的Tracker.Computation(http:// localhost:3000 / packages / tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f: 206:10)

Project.html - 客户端文件夹

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

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

< / div>
< / template>

Projectlist.js - 客户端文件夹

  Template.projectslist.dtProjects = function(){
return {
id:my-unique-table-id,
columns:[
{
title:Name,
data:name
},{
title:Description,
data:description
$ b标题:交货日期,
数据:deliverydate
}
],
订阅:dtProjects,
查询:{
grade:A
}
};
};

Server.js - 服务器文件夹

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

Projects.js - 可用于服务器和客户端:

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


解决方案

根据流星话题,JQuery dataTables重复了很多排序和DOM操作功能,MiniMongo,Spark和空格提供。因此,即使您可以将样式整理(或决定忽略样式),排序和其他功能也不会像预期的那样在数据表下面进行更新。已经这样说了,2014年7月30日,Austin Rivas,流星j ery-dat the the the the the the the of of of of of of在Meteor Google支持小组中提到的//%=nofollow> menway:jquery-datatables 包裹,以创建Meteor Datatable包)


使用jquery-datatables和流星一起做复制功能并且必须将jquery-datatables dom状态与流星反应性进行协调有很多困难。


因此,检查另一个包可能是一个好主意,或者可能检查分页的替代方法: https://github.com/awatson1978/clinical-ui-crud-table



我个人建议您使用反应表 https:// git hub.com/ecohealthalliance/reactive-table 。这是相当稳定,易于实施/配置。



另请参见:




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

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');

解决方案

As per meteor-talk, JQuery dataTables duplicates a lot of the sorting and DOM manipulation functions that MiniMongo, Spark, and Spacebars provide. So even if you can get the styling sorted out (or decided to ignore styling), sorting and other functions wind up not behaving like one is expecting when the table reactively updates underneath DataTables.

Having said so, on July 30, 2014 Austin Rivas, the creator of the meteor-jquery-datatables (which menway - creator of the menway:jquery-datatables package forked to create the Meteor Datatable package) mentioned in Meteor Google support groups:

There are lots of difficulties with using jquery-datatables and meteor together do to duplicate functionality and having to reconcile jquery-datatables dom state with meteor reactivity.

So it might be a good idea to check another package or possibly check alternative approaches for pagination: https://github.com/awatson1978/clinical-ui-crud-table

Personally I would recommend Reactive Table https://github.com/ecohealthalliance/reactive-table. It is quite stable, easy to implement / configure.

See also:

这篇关于JQuery DataTable不能在Meteor上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆