mardi 24 novembre 2015

Ember Component does not get model change

I'm relatively new to Ember.js and there are some things I dont really get so far. I use a component in my template and I pass in a model and a value. The value is used to filter the model (I also need the whole model, so i cant pass in the filtered version). When i first render it, everything is fine, but if I change the passed in value, the component empties the part, that relies on the model (hard to explain;))

index.hbs:

{{#content-view contents=contents parentId=sectionId}}{{/content-view}}

component.hbs:

<h1>Content</h1>
<p>{{parentId}}</p> //this part changes correctly
{{#each filteredContents as |fContent|}} //this part gets empty on change of parentId
    <p>{{fContent.type}}</p>
{{/each}}

component.js:

filteredContents: function() {
    return this.get('contents').filterBy('parentId', this.get('parentId'));
}.property('parentId')

As far as I get it now, the parentId is passed in correctly, and the first time the component is called, filteredContent also behaves correcty, but as soon as I change the parentId, there seems to be something wrong.




Aucun commentaire:

Enregistrer un commentaire