fiskah
fiskah

Reputation: 5902

Ember.js controller needs another controller - how do I listen for updates?

I have the following controller:

Filters.FiltersProductsController = Ember.ArrayController.extend({
    needs: "filters",
    filters: Ember.computed.alias("controllers.filters"),
    content: function(){
        return this.store.findQuery('product', this.get('filters').getFilterParams());
    }.property()
});

On the initial page load it passes along the result of getFilterParams as I want.

I have two questions:

  1. How do I listen for updates and make sure that the findQuery call is run again whenever the model data in the FiltersController is changed?
  2. Is there a smarter way of doing this?

Thanks :-)

Upvotes: 0

Views: 107

Answers (1)

GJK
GJK

Reputation: 37369

The preferred way would be to have the content property depend on the model property of the controller.

content: function() {
    return ...
}.property('controllers.filters.model')

If the filters controller is an array controller, you might want to watch content.@each instead of model.

Upvotes: 1

Related Questions