jQuery的模板与数据绑定插件

今天重典在群上说的这个,记录一下,以备后查。

ASP.NET AJAX 4.0中提供了客户端的数据绑定功能,相信大家都听说过了吧,有兴趣的可以看:Using ASP.NET AJAX Templates

废话不说,直接推荐两个jQuery的模板插件:

Chain.js

Hackszine.com: Chain.js - data binding for jQuery
http://www.hackszine.com/blog/archive/2008/08/chainjs_data_binding_for_jquer.html

Data Binding Solution for jQuery
Chain.js - Data Binding Service for jQuery
Interaction.js - drag/drop/sort support for Chain.js

Chain.js这个不错,模板可以很干净.还支持拖动、排序、事件绑定等等...

Demos:Demos for chain.jsDemos for interaction.js

image

点execute后的结果:

image

 

还有一个:

jTemplates - template engine in JavaScript
http://jtemplates.tpython.com/

这个带点入侵性,需要在模板中写上额外的标记!例如:

{#template MAIN}
 <div id="header">{$T.name}</div>
 <table>
 {#foreach $T.table as r}
  {#include row root=$T.r}
 {#/for}
 </table>
{#/template MAIN}

{#template row}
 <tr bgcolor="{#cycle values=['#AAAAEE','#CCCCFF']}">
  <td>{$T.name.bold()}</td>
  <td>{$T.age}</td>
  <td>{$T.mail.link('mailto:'+$T.mail)}</td>
 </tr>
{#/template row}
当然,看着这些标记,都可以知道这个在模板处理上可能要强些....
同类的jQuery客户端数据绑定插件还有好几个,相对功能略差,就不提了....
posted on 2008-11-27 23:42  Q.Lee.lulu  阅读(7670)  评论(26编辑  收藏  举报