首页 > Web开发 > 详细

JsRender系列demo(5) for else

时间:2014-07-27 22:35:29      阅读:366      评论:0      收藏:0      [点我收藏+]
<!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>

  

 

JsRender系列demo(5) for else,布布扣,bubuko.com

JsRender系列demo(5) for else

原文:http://www.cnblogs.com/alphafly/p/3871516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!