Add a one second delay between query input and filtering history

This commit is contained in:
Siteshwar Vashisht 2013-10-22 23:45:32 +05:30
parent aed26f8c1e
commit 119dd06ea8
2 changed files with 12 additions and 1 deletions

View file

@ -216,6 +216,17 @@ controllers.controller("historyController", function($scope, $http, $timeout) {
$scope.historyItems.splice(index, 1); $scope.historyItems.splice(index, 1);
})}; })};
var queryInputTimeout = null;
$scope.$watch("queryInput", function() {
if (queryInputTimeout){
$timeout.cancel(queryInputTimeout);
}
queryInputTimeout = $timeout(function() {
$scope.query = $scope.queryInput;
}, 1000);
});
$scope.fetchHistory(); $scope.fetchHistory();
}); });

View file

@ -1,6 +1,6 @@
<div id="table_filter_container"> <div id="table_filter_container">
<span ng-show="loadingText.length > 0"> {{ loadingText }} </span> <span ng-show="loadingText.length > 0"> {{ loadingText }} </span>
<input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query"> <input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="queryInput">
</div> </div>
<table class="data_table"> <table class="data_table">
<tbody> <tbody>