2011-11-23 66 views
0

當我使用下面的jQuery模板:淘汰賽給予<tbody>的班級第一<tr>

<script id="cost-template" type="text/x-jquery-tmpl"> 
    <table class="costSection"> 
     <caption class="boldCaption">Costs</caption> 
     <tr data-bind="css: {'alert-message block-message': quantityWarning}"> 
      <td class="labelHalfTd ">Total Quantity:</td> 
      <td class="dataHalfTd numericInfo" id="totalQuantity" data-bind="text: quantity"></td> 
     </tr> 
     <tr> 
      <td class="labelHalfTd">Cost (USD):</td> 
      <td class="dataHalfTd numericInfo" id="costUsd" data-bind="text:cost.displayValue"></td> 
     </tr> 
    </table>  
</script> 

淘汰賽正確評估數據綁定,但我們與alert-message block-message類上<tbody>,而不是擁有數據的<tr>結束-bind。在其他情況下,具有數據綁定的行不是表中的第一行,一切正常。

+1

你有沒有嘗試在'tbody'中包裝'tr's?我認爲瀏覽器正在添加'tbody'並將屬性與第一行混淆。 – natedavisolds

+0

@natedavisolds嚴重的趕上!那就是訣竅。 – Chris

+0

我發佈了答案。 – natedavisolds

回答

2

你有沒有嘗試在tbody包裹trs?我認爲瀏覽器正在添加tbody並將屬性與第一行混淆。