-
-
Save is8r/cf0c15e0863393af2637 to your computer and use it in GitHub Desktop.
Tablesorterプラグインでソートしたくない列をデータ属性(data-sorter="false")で指定する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".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