Skip to content

Commit

Permalink
trigger change:filterValue event when a filter is set
Browse files Browse the repository at this point in the history
  • Loading branch information
zarlex committed Jun 12, 2017
1 parent f56ad29 commit 498befe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/mw-backbone/collection/filterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,24 @@ mwUI.Backbone.Filterable = function (collectionInstance, options) {
return _sortOrder;
};

this.setFilters = function (filterMap) {
this.setFilters = function (filterMap, options) {
options = options || {};

_.forEach(filterMap, function (value, key) {
if (_.has(this.filterValues, key)) {
this.filterValues[key] = value;
var filterValue = {};
filterValue[key] = value;
if(_.isUndefined(options.silent) || !options.silent){
collectionInstance.trigger('change:filterValue', filterValue);
}
} else {
throw new Error('Filter named \'' + key + '\' not found, did you add it to filterValues of the model?');
}
}, this);

this.setPage(1);
this.filterIsSet = true;

};

this.getFilters = function () {
Expand Down

0 comments on commit 498befe

Please sign in to comment.