Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テーブル内の情報はすでに並べ替えられている場合があるため、ユーザーがヘッダーをクリックすると、プラグインは同じ順序で再度並べ替えますが、何も起きていないように見えます。情報がすでにソートされているかどうかを検出する方法はありますか?
ある種のインジケーターを設定します。つまり、列ヘッダー要素にデータ属性data-sorted = "true"を設定し、再度並べ替える前に確認します。jQueryコードのサンプルを次に示します。
$(".column-header").click(function(event) { event.preventDefault(); if (!$(this).data("sorted")) { // do sorting } });
ソート方向を変更する場合は、異なる値を使用できます:asc/desc。