LoginSignup
1
1

More than 5 years have passed since last update.

DataTablesのorderイベントのサンプルが間違えている

Last updated at Posted at 2014-10-30

jQueryでデータテーブルを使うとしたらほぼ一択しかないと思われる DataTables ですが、ドキュメントの間違いを見つけたので報告です。
http://datatables.net/reference/event/order

こんな感じのExampleがあるんですが、

$('#example').dataTable();

$('#example').on( 'order.dt', function () {
    // This will show: "Ordering on column 1 (asc)", for example
    var order = this.api().order();
    $('#orderInfo').html( 'Ordering on column '+order[0][0]+' ('+order[0][1]+')' );
} );

これ、こうしないと動かないです。

var table = $('#example').DataTable();
$('#example').on( 'order.dt', function (e,setting) {
    //var order = this.api().order();
    var order = table.order();
    $('#orderInfo').html( 'Ordering on column '+order[0][0]+' ('+order[0][1]+')' );
}

QAITで教えて貰ってやっと解決した。
これが出来なくて2時間も残業したお…
(´・ω・`)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1