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模板渲染引擎的详细用法第三篇的更多相关文章

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

    jquery jtemplates.js模板渲染引擎的详细用法第二篇 关于jtemplates.js的用法在第一篇中已经讲过了,这里就直接上代码,不同之处是绑定模板的方式,这里讲模板的数据专门写一个t ...

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

    jquery jtemplates.js模板渲染引擎的详细用法第一篇 Author:ching Date:2016-06-29 jTemplates是一个基于JQuery的模板引擎插件,功能强大,有了 ...

  3. template.js 数据渲染引擎

    template.js 数据渲染引擎 template.js是一款JavaScript模板引擎,用来渲染页面的. 原理:提前将Html代码放进编写模板 <script id="tpl& ...

  4. jquery validate.js表单验证的基本用法入门

    这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...

  5. jquery.tmpl.js 模板引擎用法

    1.0 引入: <script src="/js/jquery.tmpl.min.js"></script> 2.0 模板: <script type ...

  6. nunjucks.js模板渲染

    直接用 script 引入文件: <script src="nunjucks.js"></script> 是使用 render 来直接渲染文件,这种方式支持 ...

  7. Html模板渲染引擎Hogan

    Github:https://github.com/twitter/hogan.js 最简单的使用教程:http://www.imooc.com/article/18493

  8. AI (Adobe Illustrator)详细用法(三)

    本文主要是介绍和色彩相关的用法. 一.路径外观设置 1.设置描边粗细 手动输入20px 下拉选择 鼠标选中数值,按向上或向下的箭头调整 在右边的描边菜单中修改 Note:按住shift键,然后上下箭头 ...

  9. (4)Flask项目模板渲染初体验

    一.准备静态资源 将项目使用到的静态资源拷贝到static目录 二.创建前台首页html 创建templates/home/home.html页面,内容包含导航和底部版权两部分,中间内容区域为模板标签 ...

随机推荐

  1. uboot 2013.01 s3c6400编译失败

    通常我们对s3c6410平台开发u-boot是在s3c6400的基础上修改而成的,但是从uboot 2013.01这个版本之后的版本都把smdk6400对应的配置给删除了. 这是因为该版本smdk64 ...

  2. Spring Boot2.0之Admin-UI分布式微服务监控中心

    前面https://www.cnblogs.com/toov5/p/9823353.html  说的很不好用哈哈 还需要json格式化 我们可以用Admin-UI 比较爽歪歪 原理: 将所有服务的监控 ...

  3. Contiki 2.7 Makefile 文件(五)

    4.第四部分 (1) oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}} 自定义函数,$(1)表示调用oname这个函数的第一个参数,patsub ...

  4. matlab的数组

    1.定义:同一类型的元素的集合. 2.生成:用[]创建,元素之间用逗号或者空格隔开. 第一例: >>a=[1,2,3,4] a = 1 2 3 4 注意,取矩阵的某几列,是这样a(:,2: ...

  5. matlab之flipud()函数

    此函数实现矩阵的上下翻转.fliplw()实现左右旋转. 举例: a =[1 2;3 4;5 6] flipud(a)的结果: 5 6 3 4 1 2 fliplr(a)的结果: 2 1 4 3 6 ...

  6. android自定义控件(五) 自定义组合控件

    转自http://www.cnblogs.com/hdjjun/archive/2011/10/12/2209467.html 代码为自己编写 目标:实现textview和ImageButton组合, ...

  7. 机器学习:Colorization using Optimization

    今天介绍 Siggraph 2004 年的一篇文章: Colorization using Optimization,利用优化的方法对灰度图像进行着色,这里用到了非常经典的泊松方程以及稀疏矩阵的线性优 ...

  8. MySQL文本处理函数2_20160921

     需求:从目前的 test_a03order 表里面提取出来产品规格,押金的数据 一.首先添加表字段我们在表里面添加这两个字段 命名为product_size,deposit 后期进行更新这两个字段内 ...

  9. P1912 [NOI2009]诗人小G[决策单调性优化]

    地址 n个数划分若干段,给定$L$,$p$,每段代价为$|sum_i-sum_j-1-L|^p$,求总代价最小. 正常的dp决策单调性优化题目.不知道为什么luogu给了个黑题难度.$f[i]$表示最 ...

  10. Linux中vsftpd安装和配置

    目录 Redhat/CentOS安装vsftp软件 Ubuntu/Debian安装vsftp软件 Redhat/CentOS安装vsftp软件 1. 安装vsftp $ yum install vsf ...