2012-02-21 4 views
1

특정 속성을 기반으로하는 목록이 하위 목록을 반환합니다. 이 속성을 외부 컨트롤과 바인딩 할 수 있으므로 필터링 된 목록보기가 설정되면이를 새로 고칠 수 있습니다. 지금 내가 할 경우filterProperty를 특정 값으로 바인딩하여 필터링 된 목록보기를 업데이트하는 방법

: 필터링 된 목록이 필터링 된 속성 목록에 iconareacolor를 추가 할 필요가

{{#each MyApp.widgetIconsController.filtered}} 
    {{#view MyApp.IconView txtBinding ="this"}} 
     <div> {{unbound txt.widgetName}} </div> 
    {{/view}} 
{{/each}} 

MyApp.widgetIconsController = Ember.ArrayProxy.create 
    iconareacolor: null 

    content: [ 
    MyApp.ButtonWidget.create({'theme': 'lightblue'}), 
    MyApp.TextWidget.create({'theme': 'lightblue'}), 
    MyApp.ButtonWidget.create({'theme': 'lightcoral'}), 
    MyApp.TextWidget.create({'theme': 'lightcoral'}), 
    MyApp.InputWidget.create({'theme': 'lightcoral'}) ] 

    filtered: (-> 
    filteredList = this.get("content").filterProperty 'theme', this.get('iconareacolor') 
).property("[email protected]").cacheable() 

답변

2

변경하지 않은

MyApp.widgetIconsController.set 'iconareacolor', 'lightBlue'

. 재산 목록에 iconareacolor 문제가 해결되지 않은

.property("[email protected]", "iconareacolor")

+0

추가, 난 데모 [http://jsfiddle.net/lily/AR7Kr/](http://jsfiddle.net/lily/AR7Kr을 게시 /), 'blue'또는 'red'라는 텍스트를 클릭하면 필터링 된 목록이 표시됩니다. – lilyfrommars

+0

'color'로 철자를 기입하고 'color'로 철자했습니다. 국제 영어와 영국 영어가 문제를 일으켰습니다. 내 대답과 jsfiddle을 업데이트했습니다 : http://jsfiddle.net/tomwhatmore/AR7Kr/1/ –

+0

마침내 Ember.ArrayProxy.create를 사용하는 대신 Ember.ArrayController.create를 사용해야합니다. 여기에 작업 데모가 있습니다. [link] (http://jsfiddle.net/lily/jcpAs/) – lilyfrommars

관련 문제