zoukankan      html  css  js  c++  java
  • JsRender系列demo(5) for else

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script type="text/javascript" src="scripts/jquery.js"></script>
        <script type="text/javascript" src="scripts/jquery-ui.js"></script>
        <script type="text/javascript" src="scripts/jsrender.js"></script>
        <link href="scripts/demos.css" rel="stylesheet" />
        <link href="scripts/movielist.css" rel="stylesheet" />
    </head>
    <body>
        <script id="movieTemplate" type="text/x-jsrender">
            <tr>
                <td>{{:title}}</td>
                <td>{{for languages}}
                    <div class="{{:#index%2 ? 'even' : 'odd'}}"></div>
                    <em>{{:name}}</em>
                    {{else}}
                    No alternate languages!
                    {{/for}}</td>
            </tr>
        </script>
        <h2>Using {{for}} to render hierarchical data - inline nested template.</h2>
        <table>
            <thead>
                <tr>
                    <th>title</th>
                    <th>movieList</th>
                </tr>
            </thead>
            <tbody id="movieList"></tbody>
        </table>
    
    
        <script type="text/javascript">
            var movies = [
    		{
    		    title: "Meet Joe Black",
    		    languages: [
    				{ name: "English" },
    				{ name: "French" }
    		    ]
    		},
    		{
    		    title: "Eyes Wide Shut",
    		    languages: [
    				{ name: "French" },
    				{ name: "Mandarin" },
    				{ name: "Spanish" }
    		    ]
    		},
    		{
    		    title: "The Inheritance",
    		    languages: [
    				{ name: "English" },
    				{ name: "German" }
    		    ]
    		},
    		{
    		    title: "Local Story",
    		    languages: []
    		},
    		{
    		    title: "My Home Video"
    		}
            ];
            $("#movieList").html($("#movieTemplate").render(movies));
        </script>
    </body>
    </html>
    

      

  • 相关阅读:
    ActiveMQ, Qpid, HornetQ and RabbitMQ in Comparison
    AMQP与QPID简介
    设置JVM内存溢出时快照转存HeapDump到文件
    How to find configuration file MySQL uses?
    linux命令行模式下实现代理上网
    CAS分析——Core
    单点登录加验证码例子
    统一建模语言(UML) 版本 2.0
    UML 2中结构图的介绍
    如何更改 RSA 的语言设置
  • 原文地址:https://www.cnblogs.com/alphafly/p/3871516.html
Copyright © 2011-2022 走看看