Created
January 12, 2013 08:42
-
-
Save ankitnetwork18/4516793 to your computer and use it in GitHub Desktop.
jquery: jquery templating demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>jQuery templating</title> | |
<script src="jquery.js"></script> | |
<script src="jquery-templating.js"></script> | |
<script> | |
jQuery(function($){ | |
//create array or object of values to append in html | |
var movies = [ | |
{ Name: "The red volin", ReleaseYear: "1998" }, | |
{ Name: "Eyes wide shut", ReleaseYear: "2012" }, | |
{ Name: "The inheritence", ReleaseYear: "1976" } | |
]; | |
//trigger jquery templating on defined template | |
$("#movieTemplate").tmpl(movies).appendTo("#movieList"); | |
}); | |
</script> | |
</head> | |
<body> | |
<!-- define jquery template in html --> | |
<script id="movieTemplate" type="text/x-jquery-tmpl"> | |
<li> | |
<b>${Name}</b> (${ReleaseYear}) | |
</li> | |
</script> | |
<!-- write the jquery template data --> | |
<ul id="movieList"></ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment