Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created January 26, 2012 12:41
Show Gist options
  • Select an option

  • Save ppcano/1682597 to your computer and use it in GitHub Desktop.

Select an option

Save ppcano/1682597 to your computer and use it in GitHub Desktop.
example ember view
App.BrandCategoriesView = Em.CollectionView.extend({
elementId: 'brand_categories',
content: App.brandCategoriesController,
selectedCategoryBinding: Em.Binding.oneWay('App.selectedCategoryController.content'),
tagName: 'ul',
itemViewClass: Em.View.extend( App.bTap, {
classNameBindings: ['selected'],
selected: Em.computed(function(){
return ( Em.getPath(this, 'parentView.selectedCategory.id') === this.getPath('content.id') );
}).property('parentView.selectedCategory'),
bTap: function(){
console.log('brandCategories tapEnd....');
var id = this.get('content').id
, categories = Fx.Categories
, category;
var i = categories.length;
while(i-- && !category) {
if (categories[i].id === id) {
category = categories[i];
}
}
//console.log('click on ' + this.get('content').id + ' category ' + category.id);
App.selectedCategoryController.set('content', category);
},
templateName: 'brand_category'
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment