Skip to content
Browse files

Fixing race #17

  • Loading branch information...
1 parent 8d7b710 commit 68a5d7546ece1544f56c194f39113e0a4d6fb84a @mwl mwl committed Sep 11, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 sc-web/src/main/webapp/js/application.js
View
10 sc-web/src/main/webapp/js/application.js
@@ -151,14 +151,20 @@ module.directive("conceptTree", function($compile, $http) {
};
});
-module.directive('typeahead', function($http) {
+module.directive('typeahead', function($http, $log) {
return {
require: 'ngModel',
link: function(scope, elm, attr, ngModel) {
$(elm).typeahead({
source: function(query, process) {
+ var query = scope.searchQuery
$http.get("/drugs/search?q=" + scope.drugQuery).success(function(data, status) {
- process(data)
+ if (query === scope.searchQuery) {
+ process(data)
+ }
+ else {
+ $log.info("Threw away response for \"" + query + "\"")
+ }
})
},
updater: function(item) {

0 comments on commit 68a5d75

Please sign in to comment.
Something went wrong with that request. Please try again.