0

我正在尝试用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>
4

1 回答 1

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'
          }
        });
});
于 2014-03-26T15:44:14.540 回答