From 32f885f937a4457cca7de15e606d2c2a3bd70896 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 20 Sep 2014 16:38:41 +0100 Subject: Prevent form submission (page reload) issues with the search box --- scripts.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts.js b/scripts.js index 0a9e221..a408c6d 100644 --- a/scripts.js +++ b/scripts.js @@ -129,10 +129,6 @@ var isCollapsed = false; } - /* Highlight search box text on click */ - $("#searchbox").click(function () { - $(this).select(); - }); /* Typeahead search functionality */ LS.getData(function(data) { @@ -251,8 +247,20 @@ sitesBH.initialize(); + var $searchbox = $("#searchbox"); + + /* Highlight search box text on click */ + $searchbox.click(function () { + $(this).select(); + }); + + // prevent the page reloading + $searchbox.submit(function () { + return false; + }); + /* instantiate the typeahead UI */ - $("#searchbox").typeahead({ + $searchbox.typeahead({ minLength: 1, highlight: true, hint: false -- cgit v1.2.3