Search code examples
javascriptbackbone.jsmarionette

How to handle multiple marionette CollectionViews sharing the same collection


I've got a single page that needs to show multiple little boxes of the same collection sorted different ways.

Is there an event I can use to sort the collection just before rendering and use the same collection in all of the CollectionViews? Or should I make N copies of the collection sorted different ways and wire up the events myself?

I'd really like for all of the views to update when I add/remove an item from the collection.


Solution

  • CollectionView allows for a custom viewComparator option if you want your CollectionView's children to be rendered with a different sort order than the underlying Backbone collection uses.