【问题标题】:Jquery template calling only once the functionjquery模板只调用一次函数
【发布时间】:2012-11-21 10:49:54
【问题描述】:
<script id="movieTemplate" type="text/x-jquery-tmpl"> 
  <tr class='title'>
       <th>Director </td>
       <th>Name </th></tr> 
  <tr class='title'>
       <td>${Name}</td>
       <td>${Director}</td></tr>

</script>

$( "#movieTemplate" ).tmpl( movies ).appendTo( "#movieList" );

在这个模板中,我只想调用一次标题。 但是因为我不止一次调用模板,所以它调用了所有次数并且我被打印了多次。

我只想打印一次(执行):

<th>Director </td>
       <th>Name </th></tr> 

如何使用模板做到这一点。我有什么遗漏吗

【问题讨论】:

    标签: jquery jquery-templates


    【解决方案1】:

    调用前

    <tbody id="movieList"></tbody>, I called
    
           <th> Director</th>.
    
    Its like:
    
           <table>
           <th> Director </th>
       and than the template
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多