I ran into the following problem: I've a controller and I want to filter the models, something like:
App.ProductsController = Ember.ArrayController.extend({
itemController: 'product',
filteredContent: function(query) {
var query = this.get('query')
var products = this.get('content').filter(function(item) {
return true // Condition goes here
})
return products
}.property('query')
})
Which is working fine in my view:
{{#each product in filteredContent}}
...
<h1>{{product.name}}</h1>
...
<button {{action addToCart}}>Add to cart</button>
{{/each}}
At least as far as looping. The action addToCart
doesn't work and leads to the error Nothing handled the event 'addToCart'
when hitting the button. Even though it's defined in the ProductController
.
Now here is the interesting part: if I don't use the filtered results, but just each product in controller
in my view, the addToCart
click is working. I guess there's something about the relation between views and controllers I don't understand, so I appreciate any help.
Thanks!