From 72e4d5417836faa3bc23e21d1054bc6c298bf4ae Mon Sep 17 00:00:00 2001 From: Joris Steyn Date: Sat, 11 Jan 2014 12:03:01 +0100 Subject: Typeahead workaround for having to press enter twice Currently, one has to press enter twice in order to submit the package search form with typeahead completion. Add a workaround to fix this. Signed-off-by: Lukas Fleischer --- web/html/home.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/html/home.php b/web/html/home.php index e80efaa..62c246a 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -124,6 +124,15 @@ $(document).ready(function() { return item; } }).attr('autocomplete', 'off'); + + $('#pkgsearch-field').keydown(function(e) { + if (e.keyCode == 13) { + var selectedItem = $('ul.pkgsearch-typeahead li.active'); + if (selectedItem.length == 0) { + $('#pkgsearch-form').submit(); + } + } + }); });