3
jQueryプラグインテーブルコントロールのカスタムtextExtractionを設定しています(これはおそらく無関係です)。 JavaScriptコードのスニペットは次のとおりです。jQuery find()は、ChromeやFirefoxでは動作しません。
var searchResultsTables = $("table.FilterClass");
searchResultsTables.tablesorter({
widgets: ['zebra'],
widgetZebra: { css: ["Odd", "Even"] },
headers:
{
3: { textExtraction: function (node)
{
return $(node).find("img").length;
}
},
4: { sorter: false }
}
}
);
ノードは<td>
です(私は信じています)。一部の細胞にはイメージがあり、他の細胞にはイメージがありません。したがって、基本的に、この列は0/1に基づいてソートされます。その他の列はすべて整列しています(5番目の列を除いて、表示できますが、ソート可能ではありません)。
<table class="SearchResultsTable FilterClass tablesorter">
<tr class="Odd">
<td class="SearchResultsCell RightBrownBorder NameCell">
<a href="/Candidate/2">Bill Clinton</a></td>
<td class="SearchResultsCell RightBrownBorder PartyCell">Democrat</td>
<td class="SearchResultsCell RightBrownBorder DistrictCell"></td>
<td class="SearchResultsCell RightBrownBorder IncumbentCell">
<img src="/Images/green_check_mark.gif" />
</td>
<td class="SearchResultsCell PoliticalSpectrumIndexCell"></td>
</tr>
<tr class="Even">
<td class="SearchResultsCell RightBrownBorder NameCell">
<a href="/Candidate/13">Newt Gingrich</a></td>
<td class="SearchResultsCell RightBrownBorder PartyCell" title="Party for Socialism and Liberation">Party for...</td>
<td class="SearchResultsCell RightBrownBorder DistrictCell"></td>
<td class="SearchResultsCell RightBrownBorder IncumbentCell"></td>
<td class="SearchResultsCell PoliticalSpectrumIndexCell"></td>
</tr>
これはクロムまたはFirefoxで動作しない理由を任意のアイデア:ここ
ソートが機能している時に、HTML(2行)のビットがありますか?
任意のブラウザで動作するであろうと、「ノード」は、 ''要素であることを、あなたの仮定が正しいかどうか。もちろん、より多くのコードや問題のより詳細な説明を見ることなく、問題が何であるかを言うのは難しいです。 – Pointy
これは正確なコードですか? '3:'を含む? – lonesomeday
しかし 'td'に2つ以上の' img'があると... '0'や' 1'の代わりに '2'を返します – jerone