我正在使用jQuery
tablesorter plugin
要对表进行排序,将.click()处理程序分配给
<th>
fix_table_colors(identifier)
函数,当我使用Firebug手动调用它时,它应该这样做。不过,我想在排序之后自动调用它。
<th>
s、 并分配一个新的处理程序,该处理程序只调用前一个处理程序,后跟
fix_table_colors()
.
(
This
从公认的答案到
this question
$(document).ready(function() {
$("table.torrents").tablesorter({
debug: true,
headers: {
1: { sorter: 'name' },
2: { sorter: 'peers' },
3: { sorter: 'filesize' },
4: { sorter: 'filesize' },
5: { sorter: 'filesize' },
6: { sorter: 'ratio' }
}
});
$('table.torrents thead th').each(function() {
var th = $(this);
var clickHandler = th.data('events').click[0];
th.click(function() {
clickHandler();
fix_table_colors('table.torrents');
});
});
});
虽然这在概念上是正确的,
clickHandler
在Firebug中进行了进一步的挖掘,我发现click[3]似乎保留了我正在寻找的函数(并单击[10]我的新函数)。不过,在使用tablesorter.min.js时,在第2行出现了一个“e is undefined”错误。