Skip to content

Instantly share code, notes, and snippets.

@is8r
Created March 11, 2016 02:23
Show Gist options
  • Save is8r/cf0c15e0863393af2637 to your computer and use it in GitHub Desktop.
Save is8r/cf0c15e0863393af2637 to your computer and use it in GitHub Desktop.
Tablesorterプラグインでソートしたくない列をデータ属性(data-sorter="false")で指定する
$(".js-tablesorter").each(function(index, el) {
var hasSorter = [];
$("th", el).each(function(i, e) {
if($(e).data('sorter') != undefined) {
var option = {
id: i,
sorter: $(e).data('sorter')
};
hasSorter.push(option);
}
});
var options = {headers: {}};
for (var i = 0; i < hasSorter.length; i++) {
options['headers'][hasSorter[i]['id']] = {sorter: hasSorter[i]['sorter']}
};
$(el).tablesorter(options);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment