Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (39 sloc) 1.04 KB
<!doctype html>
<title>ko.mustache.js example</title>
<script type="text/javascript" src="../lib/mustache.js"></script>
<script type="text/javascript" src="../lib/knockout-2.1.0.debug.js"></script>
<script type="text/javascript" src="../ko.mustache.js"></script>
ko.setTemplateEngine(new ko.mustacheTemplateEngine());
<!-- place for rendered template -->
<div data-bind="template: {name: 'personTemplate', foreach: people}">
<!-- mustache template -->
<script id='personTemplate' type='text/html'>
{{ name }} is <span data-bind="text: age"></span> <button data-bind="click: $parent.makeOlder">Make Older</button>
<!-- knockout model and bindings -->
<script type='text/javascript'>
var viewModel = {
people: [{
name: 'Martin',
age: ko.observable(78)
}, {
name: 'John',
age: ko.observable(21)
makeOlder: function (person) {
person.age(person.age() + 1);