Permalink
Browse files

fixed filteredCollection not getting cleared after collection reset

  • Loading branch information...
1 parent 58a898e commit 5b0b33fb35b213c48db09a60b83da5600cc09018 @charly committed May 14, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/assets/javascripts/backbone.filter.js
@@ -21,7 +21,7 @@ var Filter = {
this.originalCollection = new Backbone.Collection;
this.previousCollection = new Backbone.Collection;
this.filterCollection = this;
- this.bind("reset", this.setOriginalCollection, this)
+ this.on("reset", this.resetAllCollections, this)
},
//filterAttr("film", "city") instead of filterFilms("city")
@@ -36,7 +36,7 @@ var Filter = {
},
// previousCollection keeps track of the previous result so
- // it can refilter on that one (it should be an array actually)
+ // it can *refilter* on that one (it should be an array actually)
// TODO : consider having a filter for each attribute......
handleFilters: function(attribute, query) {
if(query == "") {
@@ -59,8 +59,9 @@ var Filter = {
// loadedCollection is a copy of this collection to store
// the original models before they get filtered
- setOriginalCollection: function(event) {
- this.originalCollection.reset(this.models)
+ resetAllCollections: function(event) {
+ this.originalCollection.reset(this.models);
+ this.previousCollection.reset(this.models);
}
}

0 comments on commit 5b0b33f

Please sign in to comment.