From: Michael M Slusarz Date: Mon, 7 Jun 2010 20:21:03 +0000 (-0600) Subject: Bug #9075: Need to update cached value if a string doesn't match anything X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d4b05d7efd05c84635268fb209d23f4d7e75de22;p=horde.git Bug #9075: Need to update cached value if a string doesn't match anything --- diff --git a/horde/js/autocomplete.js b/horde/js/autocomplete.js index f12471731..d02efdf15 100644 --- a/horde/js/autocomplete.js +++ b/horde/js/autocomplete.js @@ -101,6 +101,7 @@ Autocompleter.Base = Class.create({ if (this.knl) { this.knl.hide(); } + this.getNewVal(this.lastentry); } else if (choices.size() == 1 && this.opts.autoSelect) { this.onSelect(choices.first()); if (this.knl) { @@ -141,6 +142,7 @@ Autocompleter.Base = Class.create({ if (this.opts.indicator) { $(this.opts.indicator).show(); } + this.lastentry = entry; this.getUpdatedChoices(entry); } else if (this.knl) { this.knl.hide(); @@ -191,10 +193,16 @@ Autocompleter.Base = Class.create({ onSelect: function(entry) { - if (!entry) { - return; + if (entry) { + this.elt.setValue(this.opts.onSelect(this.getNewVal(entry))).focus(); + if (this.knl) { + this.knl.markSelected(); + } } + }, + getNewVal: function(entry) + { var bounds = this.getTokenBounds(), newval, v, ws; if (bounds[0] == -1) { @@ -209,12 +217,9 @@ Autocompleter.Base = Class.create({ newval += entry + v.substr(bounds[1]); } - this.elt.setValue(this.opts.onSelect(newval)).focus(); this.oldval = newval; - if (this.knl) { - this.knl.markSelected(); - } + return newval; } });