Skip to content

Instantly share code, notes, and snippets.

@elffey
Created June 28, 2011 13:23
Show Gist options
  • Save elffey/1051120 to your computer and use it in GitHub Desktop.
Save elffey/1051120 to your computer and use it in GitHub Desktop.
// the view:
NB.NavigationMenuView = SC.TemplateCollectionView.extend({
layerId: 'navigation',
classNames: ['navigation', 'modules-list'],
contentBinding: 'NB.modulesController.content',
itemView: SC.TemplateView.extend({
templateName: 'navigation',
submenu: SC.TemplateCollectionView.extend({
contentBinding: '.parentView.content.menuItems',
itemView: SC.TemplateView.extend({
buttonPressed: function() {
console.log(this.get('content')); // item is ready
},
hash: function() {
console.log(this.get('content')); // item is BUSY_LOADING
return '#!/' + this.getPath('content.hash'); // template just gets #!/undefined
}.property('content')
})
})
})
});
// the template:
<h3 class="head"><a>{{content.title}}</a></h3>
{{#collection submenu}}
{{#view SC.Button action="buttonPressed"}}
<a {{bindAttr href="parentView.hash"}}>{{parentView.content.title}}</a>
{{/view}}
{{/collection}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment