Skip to content

Commit

Permalink
Code clean up and relax server side filter's restriction on being in …
Browse files Browse the repository at this point in the history
…server mode
  • Loading branch information
wyuenho committed Dec 30, 2013
1 parent 4d92adc commit edce3b6
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions backgrid-filter.js
Expand Up @@ -119,21 +119,17 @@
if (e) e.preventDefault();

var data = {};
var query = this.searchBox().val();
if (query) data[this.name] = query;

var collection = this.collection;

// go back to the first page on search
if (Backbone.PageableCollection &&
collection instanceof Backbone.PageableCollection &&
collection.mode == "server") {
collection.state.currentPage = collection.state.firstPage;
collection instanceof Backbone.PageableCollection) {
collection.getFirstPage({data: data, reset: true, fetch: true});
}
else {
var query = this.searchBox().val();
if (query) data[this.name] = query;
}

collection.fetch({data: data, reset: true});
else collection.fetch({data: data, reset: true});
},

/**
Expand All @@ -152,12 +148,10 @@

// go back to the first page on clear
if (Backbone.PageableCollection &&
collection instanceof Backbone.PageableCollection &&
collection.mode == "server") {
collection.state.currentPage = collection.state.firstPage;
collection instanceof Backbone.PageableCollection) {
collection.getFirstPage({reset: true, fetch: true});
}

collection.fetch({reset: true});
else collection.fetch({reset: true});
},

/**
Expand Down Expand Up @@ -332,7 +326,7 @@
},

/**
Clears the search box and reset the collection to its original.
Clears the search box and reset the collection to its original.
If the collection is a PageableCollection, clearing will go back to the
first page.
Expand Down

0 comments on commit edce3b6

Please sign in to comment.