Skip to content

Instantly share code, notes, and snippets.

@wookiehangover
Created April 17, 2011 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wookiehangover/924315 to your computer and use it in GitHub Desktop.
Save wookiehangover/924315 to your computer and use it in GitHub Desktop.
{
'groups': [
{
'id': 1,
'name': 'jQuery Team',
'children': [
{
'id': 2,
'name': 'John Resig'
},
{
'id': 3,
'name': 'Dave Methvin'
},
{
'id': 4,
'name': 'Yehuda Katz'
},
{
'id': 5,
'name': 'Julian Aubourg'
},
{
'id': 6,
'name': 'Anton Matzneller'
}
]
},
{
'id': 7,
'name': 'jQuery UI Team',
'children': [
{
'id': 8,
'name': 'Richard Worth'
},
{
'id': 9,
'name': 'Scott González'
},
{
'id': 10,
'name': 'Jörn Zaefferer'
},
{
'id': 11,
'name': 'Todd Parker'
},
{
'id': 12,
'name': 'Adam Sontag'
}
]
}
]
}
<script id="category-template" type="text/x-jquery-tmpl">
{{if groups.length}}
{{each groups}}
<li data-catId="${id}">
{{tmpl($value) '#category-content-template'}}
{{if children}}
<ul class="category-child" data-catId="${id}">
{{each children}}
<li data-catId="${id}">{{tmpl($value) '#category-content-template'}}</li>
{{/each}}
</ul>
{{/if}}
</li>
{{/each}}
{{else}}
<li>No categories available.</li>
{{/if}}
</script>
<script id="category-content-template" type="text/x-jquery-tmpl">
<a href="#">${name}</a>
{{if children}}
<span class="ui-li-count">${children.length}</span>
{{/if}}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment