mirror of
https://github.com/jimeh/fancy_input.git
synced 2026-02-19 11:36:41 +00:00
auto-highlight when there is only one result so it can be selected by pressing enter/return
This commit is contained in:
@@ -131,6 +131,7 @@
|
|||||||
var terms = $.trim(this.get_value(elm, options));
|
var terms = $.trim(this.get_value(elm, options));
|
||||||
if (options.exact_match) terms = terms.split(/\s/);
|
if (options.exact_match) terms = terms.split(/\s/);
|
||||||
if ((typeof(terms) == "string" && terms != "") || (typeof(terms) == "object" && terms.length > 0)) {
|
if ((typeof(terms) == "string" && terms != "") || (typeof(terms) == "object" && terms.length > 0)) {
|
||||||
|
this.selected_result = null;
|
||||||
if (typeof(options.url) === "string" && options.url !== "") {
|
if (typeof(options.url) === "string" && options.url !== "") {
|
||||||
this.query_for_data(elm, options);
|
this.query_for_data(elm, options);
|
||||||
} else {
|
} else {
|
||||||
@@ -216,6 +217,9 @@
|
|||||||
if (results.length > 0) {
|
if (results.length > 0) {
|
||||||
this.render(elm, results, options);
|
this.render(elm, results, options);
|
||||||
this.show();
|
this.show();
|
||||||
|
if (results.length == 1) {
|
||||||
|
this.select_next(elm, options);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
this.no_results(elm, options);
|
this.no_results(elm, options);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user