lilyfrommars
lilyfrommars

Reputation: 41

how to update filtered list view by binding filterProperty to certain value

I have a list which based on certain properties returns a sub list. Is it possible to bind this property with outside control, so when it is set, the filtered list view can refresh itself.

Right now if I do:

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

the filtered list didn't change

{{#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()

Upvotes: 1

Views: 1191

Answers (1)

Tom Whatmore
Tom Whatmore

Reputation: 1327

You need to add iconareacolor to the filtered property list.

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

Upvotes: 2

Related Questions