Meteor表格包中的数据表功能

时间:2015-03-27 04:38:26

标签: jquery meteor datatables

我已经编辑了下面的代码和解释,在进一步尝试解决之后更好地概述了问题

我试图在DataTable中添加一行(使用meteor中的aldeed:tabular创建)。我将limited instructions on tabulardetailed instructions from DataTables合并。

使用以下代码: - 表格渲染正常,所以我知道aldeed:表格是有效的 - jquery隐藏"测试"按钮在同一模板中正常工作 - 但是,单击按钮添加一行不会返回任何内容(调试器显示进程已完成,退出代码为0)

LIB /表

TabularTables = {};

Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);

TabularTables.Transactions = new Tabular.Table({
    name: "Transactions",
    collection: Transactions,
    columns: [
        {data: "company", title: "Target"},
        {data: "sector", title: "Acquirer"},
        {data: "company", title: "Enterprise Value"}
    ]
});

的客户机/ transactions.html

<template name="Transactions">
    <div>
        <div>
            <h3>Transactions</h3>
        </div>
        <div>
            <button id="addRow">Add new row</button>
        </div>
        <div>
            {{> tabular table=TabularTables.Transactions class="table table-striped table-bordered table-condensed"}}
        </div>
        <div>
            <p id="test">This is a jQuery test.</p>
            <button id="test-button">Click me</button>
        </div>
    </div>
</template>

的客户机/ transactions.js

Template.Transactions.rendered = function () {
    var t = $('TabularTables.Transactions').DataTable();
    $("#addRow").on( 'click' , function() {
        t.row.add( [
            "target",
            "acquirer",
            "1000"
        ] ).draw();
    });
    $("#test-button").click(function(){
        $("#test").hide();
    });
};

我将此发布到了软件包的问题页面以及Meteor论坛,但我认为我的问题可能是一个更通用的jquery问题,所以我认为这可能更合适。谢谢。

0 个答案:

没有答案