+ -
当前位置:首页 → 问答吧 → jQuery插件---jTemplates 模板

jQuery插件---jTemplates 模板

时间:2009-04-24

来源:互联网

<script type="text/javascript">
  $(document).ready(function() {
   //初始化数据
   var data = {
    name: '用户列表',
    list_id: '编号89757',
    table: [
     {id: 1, name: 'Rain', age: 22, mail: '[email protected]'},
     {id: 2, name: '皮特', age: 24, mail: '[email protected]'},
     {id: 3, name: '卡卡', age: 20, mail: '[email protected]'},
     {id: 4, name: '戏戏', age: 26, mail: '[email protected]'},
     {id: 5, name: '一揪', age: 25, mail: '[email protected]'}
    ]
   };
   // 附上模板
   $("#result1").setTemplateElement("template");
   // 给模板加载数据
   $("#result1").processTemplate(data);
  });
</script>
<!-- 模板内容 -->
 <textarea id="template" style="display:none">
  <strong>{$T.name} : {$T.list_id}</strong>
  <table>
         <tr>
     <th>编号</th>
     <th>姓名</th>
                    <th>年龄</th>
     <th>邮箱</th>
   </tr>
   {#foreach $T.table as record}
   <tr>
     <td>{$T.record.id}</td>
     <td>{$T.record.name}</td>
                    <td>{$T.record.age}</td>
     <td>{$T.record.mail}</td>
   </tr>
   {#/for}
  </table>
 </textarea>
=================
$T表示什么呀??

作者: caojiayin198   发布时间: 2009-04-24

搜索 jTemplates,
官方有介绍, $T应该是 数据  data  吧

作者: cssrain   发布时间: 2009-04-29

用php给的模板  {$T.record.id} 就是取数据的撒

作者: loveyouyk   发布时间: 2009-06-01

哇撒,强大.

作者: pader   发布时间: 2009-06-04

相关阅读 更多

热门下载

更多