mardi 21 avril 2015

Emberjs object loses its property after computed sort

I have a table component, which receives a model what i call content.

{{my-table content=model }}

This model get sorted into a computed property (CP).

multiSort: Ember.computed.sort('content','sortProperitsWithOrders')

I loop through the multiSort and pass each row to the a row component

  {{#each row in multiSort}} 
    {{my-table-row row=row columns=columns}}
  {{/each}}

In each row I have a checkbox component. If it changes, an action is sent up to its parent component (the row component). From the row I send the action further to the table component (action up), where I toggle the row's active property.

The problem: after I use sort, the row lose its active property, and the checkbox is unchecked. Check a checkbox then hit the header of a column.

I would think Ember.compute.sort takes the content and rearrange it based on sortProperitsWithOrders. So if I set the active property on one of the content's item, then I will have it in the multiSort CP. From multiSort it will pass down to the row component, and from the row to the checkbox (data down).

JsBin: http://ift.tt/1HRrL4k




Aucun commentaire:

Enregistrer un commentaire