Improved/Fixed Autocomplete
Change-Id: Ia4379755182d151ef26ffa790813203e1a121ad6
diff --git a/client/catalog/js/autocomplete.js b/client/catalog/js/autocomplete.js
index df54c17..d6987e2 100644
--- a/client/catalog/js/autocomplete.js
+++ b/client/catalog/js/autocomplete.js
@@ -77,12 +77,14 @@
var updateFromList = function(){
var val = input.val(); //Needs to be unfiltered, for filtering existing results.
+ var temp = lastList;
setAutoComplete(lastList.reduce(function(prev, current){
if (current.indexOf(val) === 0){
prev.push(current);
}
return prev;
}, []));
+ lastList = temp;
}
this.keydown(function(e){
@@ -127,6 +129,16 @@
e.preventDefault(); //Don't print tab or select a different element.
break;
+ case 8:
+ console.log("Detected backspace");
+ if (input.val().slice(-1) == "/"){
+ e.preventDefault();
+ input.val(input.val().slice(0,-1)); //Manually backspace early. (Have to do it manually)
+ getSuggestions(getValue(), setAutoComplete);
+ } else {
+ updateFromList(setAutoComplete);
+ }
+
default:
updateFromList();