来自ajax的Dynatable排序不起作用

时间:2014-02-20 16:55:33

标签: javascript ajax json dynatable

我正在尝试使用Dynatable加载json数据看起来不错,但无法排序,问题是什么?

这是我的JavaScript:

$(document).ready(function() {
            var dynatable = $('table').dynatable({
              dataset: {
                ajax: true,
                ajaxOnLoad: true,
                ajaxUrl: 'people.json',
                records: [],
                perPageDefault: 4,
                perPageOptions: [4,6,8,10]
              },
              params: {
                records: 'People'
              }
            }).data("dynatable");

    });

表格:

<table>
            <thead>
                <tr>
                    <th>NAME</th>
                    <th>ADDRESS</th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>

1 个答案:

答案 0 :(得分:1)

将您的表格html标记更改为

<table id="myTable">

将您的javascript更改为:

$(document).ready(function() {
    $('#myTable').dynatable({
         dataset: {
            ajax: true,
            ajaxOnLoad: true,
            ajaxUrl: 'people.json',
            records: [],
            perPageDefault: 4,
            perPageOptions: [4,6,8,10]
          },
          params: {
            records: 'People'
          }
        });
});