1
我有灰燼的應用程序有兩種視圖和控制器:如何操作列表項從它的觀點在emberjs
http://jsfiddle.net/gavriguy/EDr4G/
我要標記的當前項目的用戶的點擊閱讀 - 由改變它的相關模型。 我目前能夠通過計算視圖的項目索引來做到這一點 - 但問題是我無法確定視圖上的索引與其控制器上的索引是否相同。 有什麼想法?
的JavaScript:
App.tempController = Em.ArrayController.create({
content: [
{
title: 'A',
unread: true},
{
title: 'B',
unread: true},
{
title: 'C',
unread: false}
]
});
App.someItemsView = Ember.CollectionView.create({
contentBinding: 'App.tempController.content',
itemViewClass: Ember.View.extend({
template: Ember.Handlebars.compile('<div>{{content.title}} unread: {{content.unread}}</div>'),
click: function(event) {
//How to mark current clicked item as read?
console.log(this.content);
console.log(event);
this.set('content.unread', false);
}
})
});
謝謝,它的工作原理就像一個魅力:) – Gavriguy