fvisticot
fvisticot

Reputation: 8546

1 ArrayController, 2 collectionView with reverse order

1 have 1 ArrayController and 2 CollectionView classes (not instances) sharing this ArrayController. (contentBinding: sharedArrayController)

Both collectionView needs to display the same array content (with different rendering) BUT in the reverse order.

Render1CollectionView: obj1, obj2, obj3
Render2CollectionView: obj3, obj2, obj1

How to tell the CollectionView to iterate in a reverse order ?

Other idea ?

Upvotes: 1

Views: 282

Answers (2)

fvisticot
fvisticot

Reputation: 8546

I found the solution in another post ... and it works perfectly

reversedContent: function(){
      return this.get('content').toArray().reverse();
    }.property('content.@each').cacheable()

Upvotes: 1

sly7_7
sly7_7

Reputation: 12011

I think I would define a computed propery in the controller, and relying on it in the view (or template)

YourApp.YourController = Ember.ArrayController.extend({
    reversedContent: function(){
       return this.reverse();
    }.property('@each')
})

Upvotes: 0

Related Questions