new FilteringCollection(models, Options)
Collection which tracks another collection. Models added to the tracked collection are only added to the
FilteringCollection if they pass the modelFilter function. If the tracked model changes, the modelFilter is applied
again and if it passes the new attributes are set on the tracking model, or if it fails the model is removed.
Models removed from the tracked collection are removed from the FilteringCollection.
Parameters:
| Name | Type | Description |
|---|---|---|
models |
Array.<Backbone.Model> | Initial models |
Options |
module:js-whatever/js/filtering-collection.FilteringCollection~FilteringCollectionOptions | for the filtering collection |
- Source:
Extends
- Backbone.Collection
Methods
-
filter(filters)
-
Updates the filters data to the method parameter and re-filters the collection
Parameters:
Name Type Description filtersObject New filters data
- Source:
Type Definitions
-
FilteringCollectionOptions
-
- Source:
Properties:
Name Type Argument Default Description collectionBackbone.Collection The collection to track
modelFiltermodule:js-whatever/js/filtering-collection.FilteringCollection~modelFilter filtersObject <optional>
{} Initial filters data which will be passed to the modelFilter
-
modelFilter(model, filters) → {Boolean}
-
Parameters:
Name Type Description modelBackbone.Model The model to check against the filter
filtersObject Filters data
- Source:
Returns:
True if the model passes the filter, false if not
- Type
- Boolean