1
I이 뷰와 컨트롤러를 모두 가진 엠버 응용 프로그램 :어떻게 목록 항목을 조작하는
http://jsfiddle.net/gavriguy/EDr4G/
나는 현재 항목 읽은 상태로 사용자가 클릭을 표시 할 -에 의해 관련 모델을 변경합니다. 현재 뷰의 항목 인덱스를 계산하여이를 수행 할 수 있습니다.하지만 뷰의 인덱스가 해당 컨트롤러의 인덱스와 같은지 확신 할 수 없습니다. 의견이 있으십니까?
자바 스크립트 :
당신의click
핸들러는 뷰가
this.get('content')
를 통해 렌더링되는 배열 항목에 대한 참조를 얻을 수있는 내부
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