jquery jtemplates.js模板渲染引擎的详细用法第三篇

<span style="font-family:Microsoft YaHei;font-size:14px;"><!doctype html>

<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery - jTemplates</title>
<!-- <link rel="stylesheet" type="text/css" href="./css/style.css"> -->
<script type="text/javascript" src="./js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="./js/jquery-jtemplates.min.js"></script>
<style type="text/css">
.container{
width: 1000px;
height: 600px;
margin: 0 auto;
}
.template{
display: none;
}
table{
background-color: #fff;
}
table tr th{
padding: 8px;
border-bottom: 1px solid #eee;
}
table tr td{
padding: 10px;
border-bottom: 1px solid #eee;
}
</style>
<script type="text/javascript">
$(function(){
// 初始化JSON数据
// 通过getJSON方法加载
// $.getJSON("./data/dataSource1.json", function(data){
// // 设置模板
// $("#result").setTemplateElement("template");
// // 给模板加载数据
// $("#result").processTemplate(data);
// }); // 通过ajax方法加载
$.ajax({
type:"post",
dataType:"json",
url:"./data/dataSource1.json",
success:function(data){
// alert(data);
// 设置模板
$("#result").setTemplateElement("template");
// 给模板加载数据
$("#result").processTemplate(data);
},
error:function(error){
alert("error:" + error.responseText);
}
});
});
</script>
</head>
<body>
<div class="container">
<div><h1>标题</h1></div>
<div id="result"></div>
<textarea id="template" class="template">
{#template MAIN}
<table>
<tr>
<td>Id</td>
<td>标题</td>
<td>发布时间</td>
</tr>
{#foreach $T.Lists as r}
{#include ROW root=$T.r}
{#/for}
</table>
{#/template MAIN} {#template ROW}
<tr>
<td>{$T.Id}</td>
<td>{$T.Title}</td>
<td>{$T.CreateDate}</td>
</tr>
{#/template ROW}
</textarea>
</div>
</body>
</html></span>

  这个是一个例子

最新文章

  1. CodeForces - 241E Flights 题解
  2. 设置ASP.NET页面的运行超时时间详细到单个页面及站点
  3. BZOJ1816 [Cqoi2010]扑克牌
  4. Oracle 删除用户和表空间
  5. 嵌入式 hi3518x平台h264+g711a封装mp4代码demo
  6. db2 identity列重置,reset/restart
  7. php中soap应用
  8. Delphi版IP地址与整型互转
  9. Hat’s Words
  10. 企业级LNMP架构搭建实例(基于Centos6.x)
  11. 基于DP的矩阵连乘问题
  12. IZT复杂电磁环境记录回放和模拟系统
  13. Newtonsoft.Json(Json.net) 的使用
  14. 什么是XML?
  15. Android程序的反破解技术
  16. 微软BI 之SSIS 系列 - 理解Data Flow Task 中的同步与异步, 阻塞,半阻塞和全阻塞以及Buffer 缓存概念
  17. Blob下载文件 &amp; 模拟滚动条实现
  18. Tomcat7.0安装配置详细(图文)
  19. Toast信息框
  20. 【汉化】Acunetix Web Vulnerability Scanner 11.x汉化包

热门文章

  1. 51nod 40分算法题
  2. jetty使用jndi数据源
  3. hihocoder1075【开锁魔法】
  4. fiddler篡改请求数据
  5. hdu-5857 Median(水题)
  6. super.onCreate(savedInstanceState) 以及onCreate(Bundle savedInstanceState, PersistableBundle persistentState)
  7. bjwc Day2 玄学
  8. jQuery 下拉框输入匹配提示选项
  9. eclipse 通过maven 开发storm项目
  10. bzoj 3267: KC采花&amp;&amp;3272&amp;&amp;3638&amp;&amp;3502 线段树