码迷,mamicode.com
首页 > 其他好文 > 详细

JTemplates 的使用

时间:2017-08-17 20:13:19      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:bsp   begin   htm   javascrip   rtm   templates   src   ssi   foreach   

<script src="~/Js/jquery-2.1.0.js"></script>
<script src="~/Js/jquery-jtemplates.js"></script>
<script type="text/javascript">

    $(function ($) {

     var data=   {
 "AgentList": [ {
            "nAgentID": "2317",
            "sAgentCode": "JLS",
            "sAgentName": "九岭山"
        } ],
    "DepartmentList": [ {
            "nDepartmentID": "2",
            "sDepartmentCode": "WW",
            "sDepartmentName": "王五",
            "nAgentid": "2315"
        },  {
            "nDepartmentID": "3",
            "sDepartmentCode": "ZS",
            "sDepartmentName": "张三",
            "nAgentid": "2315"
        } ]
}

                $(‘#foreachResult‘).setTemplate($(‘#foreach‘).html()).processTemplate(data);
        

        });




</script>

<script type="text/template" id="foreach">  
    <table>  
    <thead>  
        <tr>  
           
            <td>hehehe</td>  
            <td>gagaga</td>  
            <td>hahaha</td>  
        </tr>  
    </thread>  
    <tbody>  
        {#foreach $T.AgentList as record begin=0}  
        <tr>  
            <td>{$T.record.nAgentID}</td>  
            <td>{$T.record.sAgentCode}</td>  
              <td>{$T.record.sCommission}</td>  
        </tr>  
        {#/for}  
    <p><br><br>
       {#foreach $T.DepartmentList as record begin=0}   这个begin 就是在那条记录开始,在1开始第0条省略。类推
        <tr>  
            <td>{$T.record.nDepartmentID}</td>  
            <td>{$T.record.sDepartmentCode}</td>  
              <td>{$T.record.sDepartmentName}</td>  
        </tr>  
        {#/for}
    </tbody>  
</table>  
</script>



<body>
    <div id="foreachResult"></div> 
</body>

JTemplates 的使用

标签:bsp   begin   htm   javascrip   rtm   templates   src   ssi   foreach   

原文地址:http://www.cnblogs.com/j2ee-web-01/p/7383762.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!