zoukankan      html  css  js  c++  java
  • JTemplates 的使用

    注意事项:一定要放在Jquery的页面加载完成事件内  : $(function{});

    <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>

  • 相关阅读:
    Hibernate实体类注解
    Struts2注解详解
    Spring注解大全
    Maven依赖机制
    Maven启动代理服务器
    SSH整合
    二进制求和 —— 从复杂方法到简单方法
    最大子序和 —— 动态规划解法
    括号匹配问题 —— Deque双端队列解法
    常见面试题 —— 两数之和(拒绝暴利法)
  • 原文地址:https://www.cnblogs.com/j2ee-web-01/p/7383762.html
Copyright © 2011-2022 走看看