-
-
Save duanemoody/7358179 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$(document).ready( function() { | |
$('#display').click(function () { | |
var data = [ | |
{ | |
"name": "Paul McCartney", | |
"email": "[email protected]", | |
"salary": "400" | |
}, | |
{ | |
"name": "John Lennon", | |
"email": "[email protected]", | |
"salary": "450" | |
}, | |
{ | |
"name": "George Harrison", | |
"email": "[email protected]", | |
"salary": "400" | |
}, | |
{ | |
"name": "Ringo Starr", | |
"email": "[email protected]", | |
"salary": "300" | |
} | |
]; | |
var table = ich.displayTable({ | |
"users": data | |
}); | |
$('#container').append(table); | |
}); | |
}); |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>ICanHaz.js loop demo</title> | |
<meta charset="UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/ICanHaz.js/0.10/ICanHaz.min.js"></script> | |
<script src="ich-loop.js"></script> | |
<script id="displayTable" type="text/html"> | |
<table border="1"> | |
<thead> | |
<tr> | |
<td>Name</td> | |
<td>Email</td> | |
<td>Salary</td> | |
</tr> | |
</thead> | |
<tbody> | |
{{#users}} | |
<tr> | |
<td>{{ name }}</td> | |
<td>{{ email }}</td> | |
<td>{{ salary }}</td> | |
</tr> | |
{{/users}} | |
</tbody> | |
</table> | |
</script> | |
</head> | |
<body> | |
<p> | |
ICanHaz will render each table row using mustache loop notation. | |
</p> | |
<button id="display">click to add message</button> | |
<div id="container"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTML converted to HTML5 to ensure validation.
"http://www.w3.org/tr/html4/transitional.dtd"
declares Transitional butPUBLIC "-//W3C//DTD HTML 4.01//EN"
is exclusive to 4.01 Strict).