ビューとコントローラーの両方を備えたEmberアプリケーションがあります。
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);
}
})
});