jquery jtemplates.js模板渲染引擎的详细用法第三篇
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>
这个是一个例子
jquery jtemplates.js模板渲染引擎的详细用法第三篇的更多相关文章
- jquery jtemplates.js模板渲染引擎的详细用法第二篇
jquery jtemplates.js模板渲染引擎的详细用法第二篇 关于jtemplates.js的用法在第一篇中已经讲过了,这里就直接上代码,不同之处是绑定模板的方式,这里讲模板的数据专门写一个t ...
- jquery jtemplates.js模板渲染引擎的详细用法第一篇
jquery jtemplates.js模板渲染引擎的详细用法第一篇 Author:ching Date:2016-06-29 jTemplates是一个基于JQuery的模板引擎插件,功能强大,有了 ...
- template.js 数据渲染引擎
template.js 数据渲染引擎 template.js是一款JavaScript模板引擎,用来渲染页面的. 原理:提前将Html代码放进编写模板 <script id="tpl& ...
- jquery validate.js表单验证的基本用法入门
这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...
- jquery.tmpl.js 模板引擎用法
1.0 引入: <script src="/js/jquery.tmpl.min.js"></script> 2.0 模板: <script type ...
- nunjucks.js模板渲染
直接用 script 引入文件: <script src="nunjucks.js"></script> 是使用 render 来直接渲染文件,这种方式支持 ...
- Html模板渲染引擎Hogan
Github:https://github.com/twitter/hogan.js 最简单的使用教程:http://www.imooc.com/article/18493
- AI (Adobe Illustrator)详细用法(三)
本文主要是介绍和色彩相关的用法. 一.路径外观设置 1.设置描边粗细 手动输入20px 下拉选择 鼠标选中数值,按向上或向下的箭头调整 在右边的描边菜单中修改 Note:按住shift键,然后上下箭头 ...
- (4)Flask项目模板渲染初体验
一.准备静态资源 将项目使用到的静态资源拷贝到static目录 二.创建前台首页html 创建templates/home/home.html页面,内容包含导航和底部版权两部分,中间内容区域为模板标签 ...
随机推荐
- Spring Boot2.0之热部署原理
所谓的热部署:比如项目的热部署,就是在应用程序在不停止的情况下,实现新的部署 原理: 实用类加载器(classloader重新读取字节码文件到jvm内存) 如何纯手写一个热部署功能: 1.监听 cla ...
- PHP的引用详解【转】
摘自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/09/10/2173092.html 官方文档: 1.引用是什么:http://ww ...
- 英语影视台词---无敌破坏王2大脑互联网(3)((Ralph)我们去喝根汁汽水吧)
英语影视台词---无敌破坏王2大脑互联网(3)((Ralph)我们去喝根汁汽水吧) 一.总结 一句话总结: Let's go get a root beer. 1.(Ralph)让我来瞧瞧你的本事 ...
- Eclipse_插件_03_反编译插件_Eclipse Class Decompiler
一.插件优势 此插件比jd-eclipse更加强大,反编译之后不会像jd-eclipse一样出现注释符号. 二.插件下载地址 1.github https://github.com/cnfree/Ec ...
- [Shell]grep命令
我是好文章的搬运工,原文来自ChinaUnix,博主scq2099yt,地址:http://blog.chinaunix.net/uid-22312037-id-4217835.html 一.基本用法 ...
- 【LeetCode】026. Remove Duplicates from Sorted Array
题目: Given a sorted array, remove the duplicates in place such that each element appear only once and ...
- mac内置的FTP工具
在 Mac OS X 系统下,有不少优秀的 FTP 工具,如 Cyberduck.Transmit,但是你是否知道除了这些第三方应用,系统已经为你准备好了一个内置的 FTP 工具?/ M: e0 J% ...
- BZOJ3938:Robot
浅谈标记永久化:https://www.cnblogs.com/AKMer/p/10137227.html 题目传送门:https://www.lydsy.com/JudgeOnline/proble ...
- 性能测试之Jmeter学习(九)
本节主要学习:定时器(部分内容引用http://www.cnblogs.com/yangxia-test) Meter也有像LR中的集合点,本节就来介绍下JMeter的集合点如何去实现. JMeter ...
- VMware设置桥接网络
VMware设置桥接网络 2011-12-30 08:57:04 分类: LINUX 一.桥接网络的基本原理 配置成桥接网络连接模式的虚拟机就当作主机所在以太网的一部分, 虚拟系统和宿主机器的 ...