-
Notifications
You must be signed in to change notification settings - Fork 112
Populating a list with directives
Mark Statkus edited this page Jul 18, 2014
·
3 revisions
Sample is raw javascript, json, and HTML.
{
"made-with-title": "made with:",
"made-with-items": [
{
"href": "http://leaverou.github.io/prefixfree/",
"icon": {
"src": "media/img/logos/prefixfree.jpg",
"title": "Prefix-Free"
}
},
{
"href": "http://modernizr.com",
"icon": {
"src": "media/img/logos/modernizr.jpg",
"title": "Modernizr"
}
},
{
"href": "http://jquery.com",
"icon": {
"src": "media/img/logos/jquery.png",
"title": "jQuery"
}
}
],
}
<div class="col-md-6">
<p data-bind="made-with-title"></p>
<!-- li items will repeat -->
<ul class="made-with-items">
<li>
<a data-bind="link" target="_blank">
<img class="icon" />
</a>
</li>
</ul>
</div>
directive: {
"made-with-items": {
link: {
href: function () { return this.href; }
},
icon: {
src: function () { return this.icon.src; },
title: function () { return this.icon.title; }
}
}
}
$('#yourpage').render(data, directive);