JsRender 시리즈 데모 (5)
                                            
 2432 단어  jsrender
                    
<!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>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JsRender 시리즈 demo (6) - 무명텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.