Closed jrmyio closed 9 years ago
@ConneXNL, are you using a comparator function or key string?
@latentflip, @HenrikJoreteg , @legastero: what do you think of automatically watching key strings passed as spec.comparator
?
It might also be useful to be able to have a declarative watch
list in the spec for when your comparator is a function.
@ConneXNL, #28 adds watching string comparator, as well as better docs about watches. Closing.
Let's say a use a simple comparator function that uses a property of the model.
Whenever a model changes it might need re-sorting. How to trigger the re-sorting?
Currently I'm doing from within Ampersand.SubCollection: this.listenTo(this, 'change', this._runFilters);
Is this the preferred way?
In a collection we have a .sort() function to do this: sort collection.sort([options]) Force a collection to re-sort itself. You don't need to call this under normal circumstances, as a collection with a comparator will sort itself whenever a model is added. To disable sorting when adding a model, pass {sort: false} to add. Calling sort triggers a "sort" event on the collection.