Skip to content

Commit 6698a91

Browse files
author
Nicholas Thomson
committed
don't redefine function on broadcast
1 parent 88e4ebc commit 6698a91

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

app/scripts/controllers/crunchinator.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,25 @@ angular.module('crunchinatorApp.controllers')
6464
//Bind component data services to the scope, so we can use them in the views
6565
$scope.ComponentData = ComponentData;
6666

67+
var deferred = $q.defer();
68+
function applyFilters() {
69+
_.delay(function(){
70+
$scope.$apply(function() {
71+
Company.runFilters(filterData);
72+
Category.runFilters(filterData);
73+
Investor.runFilters(filterData);
74+
75+
deferred.resolve('Finished filters');
76+
});
77+
}, 300);
78+
79+
return deferred.promise;
80+
}
81+
6782
//All of our filters broadcast 'filterAction' when they've been operated on
6883
//When a filter receives input we set up filterData and run each model's filters
6984
//This should automatically update all the graph displays
7085
$scope.$on('filterAction', function() {
71-
var deferred = $q.defer();
72-
73-
74-
function applyFilters() {
75-
_.delay(function(){
76-
$scope.$apply(function() {
77-
Company.runFilters(filterData);
78-
Category.runFilters(filterData);
79-
Investor.runFilters(filterData);
80-
81-
deferred.resolve('Finished filters');
82-
});
83-
}, 300);
84-
85-
return deferred.promise;
86-
}
87-
8886
$scope.loading = true;
8987
filterData.categoryIds = _.pluck($scope.selectedCategories, 'id');
9088
filterData.companyIds = _.pluck($scope.selectedCompanies, 'id');
@@ -102,5 +100,7 @@ angular.module('crunchinatorApp.controllers')
102100
$scope.loading = false;
103101
});
104102
});
103+
104+
105105
}
106106
]);

0 commit comments

Comments
 (0)