From 807c3b5b36f1467abb01c170771b4e05928f1434 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 31 Mar 2011 23:42:27 +0100 Subject: [PATCH] auto-highlight when there is only one result so it can be selected by pressing enter/return --- fancy_input/jquery.fancy_suggest.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fancy_input/jquery.fancy_suggest.js b/fancy_input/jquery.fancy_suggest.js index c6695a9..e255c4b 100644 --- a/fancy_input/jquery.fancy_suggest.js +++ b/fancy_input/jquery.fancy_suggest.js @@ -131,6 +131,7 @@ var terms = $.trim(this.get_value(elm, options)); if (options.exact_match) terms = terms.split(/\s/); if ((typeof(terms) == "string" && terms != "") || (typeof(terms) == "object" && terms.length > 0)) { + this.selected_result = null; if (typeof(options.url) === "string" && options.url !== "") { this.query_for_data(elm, options); } else { @@ -216,6 +217,9 @@ if (results.length > 0) { this.render(elm, results, options); this.show(); + if (results.length == 1) { + this.select_next(elm, options); + }; } else { this.no_results(elm, options); };