Tablesorter斑马没有条纹直到排序 [英] Tablesorter zebra doesnt stripe till sort
问题描述
我有我的桌子,他们很棒,我可以对它们进行排序,它的效果非常好,除非它们不进行斑马条纹,直到我第一次对它们进行排序。我的理解是,一旦表分类器初始化它们就会被条带化,是不是这样?
I have my tables and they are great I can sort them and it works wonderfully except that they don't do the zebra striping until I sort them for the first time. My understanding was that they will be striped as soon as table sorter is initialized, is this not the case?
这是来自这里的tablesorter v 2.10(最新版):< a href =http://mottie.github.io/tablesorter/docs/index.html =noreferrer> http://mottie.github.io/tablesorter/docs/index.html
This is tablesorter v 2.10 (the latest) from here: http://mottie.github.io/tablesorter/docs/index.html
推荐答案
您的问题很可能与表格不可见这一事实有关( display:none
)当你初始化表上的tablesorter时。
Your problem is most probably related to the fact that the table is not visible (display: none
) when you initialize the tablesorter on your table.
一个可能的解决方案是只有在表可见时执行以下初始化:
A possible solution is to execute the following initialization only once the table is visible with:
if($('tab_parent_of_the_table').is(':visible')) {
$("your_table_table").tablesorter({
widgets: ['zebra']
});
}
更好的解决方案是使用超时包装可见性检查,因为通常它在应用可见性更改之前完成,从而导致错误的声明。
这样做:
An even better solution is to wrap the visibility check with a timeout, since normally it is done before the change of visibility is applied, resulting in a false statement. Do like this:
setTimeout(function(){
if($('tab_parent_of_the_table').is(':visible')) {
$("your_table_table").tablesorter({
widgets: ['zebra']
});
}
}, 50);
这篇关于Tablesorter斑马没有条纹直到排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!