Using Filtered Collection
Learn how to filter contacts using FileterdCollection in Marionette.
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 FilteredCollection
. We will add the file assets/js/entities/common.js
.
Note: If you want to learn about implementation details, take a look at them in the “Appendix: Creating a FilteredCollection” chapter at the end of this course.
Before anything else, let’s include this new file in index.html
:
Get hands-on with 1400+ tech skills courses.