jQuery tmpl clear

问题描述:

有谁知道如何清除jQuery tmpl(),以便我可以重新填充它?我不能使用empty(),因为我需要父项中的其余内容。我可以使用删除,但我需要知道有多少......等等,我可能刚才计算出来:)jQuery tmpl clear

模板看起来像这样

<table id="lvList" class="grid1"> 
    <tr id="itemtemplatePlaceHolder"> 
     <th>Reference</th> 
     <th>Address</th> 
     <th>Country</th> 
     <th>Postcode</th> 
     <th>Tel</th> 
     <th>Fax</th> 
     <th style="width:50px;">Billing</th> 
     <th style="width:50px;">Shipping</th> 
    </tr> 
    <script id="itemtemplate" type="text/x-jquery-tmpl"> 
     <tr> 
      <td><a id="${id}" href="address.aspx?id=${id}" oncontextmenu="ContextMenu.Show(this,event); return false;">${reference}</a></td> 
      <td>${$item.nobreak("address", ", ")}</td> 
      <td>${country}</td> 
      <td>${postcode}</td> 
      <td>${tel}</td> 
      <td>${fax}</td> 
      <td>${$item.bool("defaultbilling", "X", "")}</td> 
      <td>${$item.bool("defaultshipping", "X", "")}</td> 
     </tr> 
    </script> 
    <tr id="footertemplate"> 
     <td colspan="8">&nbsp;</td> 
    </tr> 
</table> 
+0

你应该自我回答你自己的问题。一天之后,你也可以接受你自己的答案。 –

+0

我需要8更多的点之前,我可以自己回答:( – Christian

+0

我现在可以自我回答呐喊,并将编辑此帖子 – Christian

回答我自己的查询:)只是如果任何人有同样的问题,他就是我所做的

不停的有多少项目有在数据列表this.itemcount = data.Count();的轨道,然后取出过去不到该项目的索引占位所有的兄弟姐妹数$("#itemtemplatePlaceHolder ~ :lt(" + this.itemcount + ")").remove()

this.Populate = function() { 
    try { 
     if (this.itemcount > 0) { 
      $("#itemtemplatePlaceHolder ~ :lt(" + this.itemcount + ")").remove(); 
     } 

     var data = this.GetData(); 
     this.itemcount = data.Count(); 

     $("#itemtemplate").tmpl(data).insertAfter("#itemtemplatePlaceHolder"); 
    } 
    catch (ex) { this.HandleError(ex); } 
};