Using Filtered Collection
Explore filtering techniques in Marionette.js by using a FilteredCollection to automatically manage filtered contact data. Learn to implement a collection that refreshes views on filter changes, handle edge cases in item views, and ensure robust application behavior when filtering contact lists.
We'll cover the following...
We need to filter our contacts collection and reset its contents to only have those models that match the filtering criterion. However, there’s a cleaner, more encapsulated way of thinking about the problem. We could create a special collection that would filter itself. Then, we’d simply pass that special collection to the composite view. Each time we execute the filtering function, the view will refresh itself automatically since it listens to the collection’s "reset" event.
Filtering contacts
We’ll follow the second approach using the ...