jQuery Template

JavaScript/jQuery 2011. 12. 27. 18:41

http://api.jquery.com/category/plugins/templates/ 



<!DOCTYPE html>

<html>

<head>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>

  <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>

</head>

<body>

  

<script id="movieTemplate" type="text/x-jquery-tmpl"> 

    <li>

        Title: ${Name} ${index}

        {{each Languages}}

            ${$index + 1}: <em>${$value}. </em>

        {{/each}}

    </li>

</script>


<ul id="movieList"></ul>


<script>

var movies = [

    { Name: "Meet Joe Black", Languages: ["French"] },

    { Name: "The Mighty", Languages: [] },

    { Name: "City Hunter", Languages: ["Mandarin", "Cantonese"] }

];


/* Render the template with the movies data */

$( "#movieTemplate" ).tmpl( movies )

    .appendTo( "#movieList" );

</script>


</body>

</html>





'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
jQuery Carousel - modular  (2) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,