我有一个有视图和控制器的 Ember 应用程序:
http://jsfidle.net/gavriguy/EDr4G/" rel="nofollow">http://jsfidle.net/gavriguy/EDr4G/
I want to mark the current item the user clicks as read - by changing it s related model. I m currently able to do that by figuring the item s index of the view - but the problem is that i can t be sure that the index on the view is the same as the index on its controller. Any thoughts?
<% 1 > JavaScript % 1 > :
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);
}
})
});