From 2c22327b56a06312804a21fe1bbd15e9419aacb6 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 29 Sep 2017 08:38:37 -0400
Subject: [PATCH] Allow autocomplete to be disabled. - Fixes VUFIND-1249.

---
 themes/bootstrap3/js/common.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index 6babc8e3a55..dd2971af62a 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -241,8 +241,13 @@ function setupOffcanvas() {
 }
 
 function setupAutocomplete() {
+  // If .autocomplete class is missing, autocomplete is disabled and we should bail out.
+  var searchbox = $('#searchForm_lookfor.autocomplete');
+  if (searchbox.length < 1) {
+      return;
+  }
   // Search autocomplete
-  $('#searchForm_lookfor').autocomplete({
+  searchbox.autocomplete({
     maxResults: 10,
     loadingString: VuFind.translate('loading') + '...',
     handler: function vufindACHandler(input, cb) {
@@ -278,7 +283,7 @@ function setupAutocomplete() {
   });
   // Update autocomplete on type change
   $('#searchForm_type').change(function searchTypeChange() {
-    $('#searchForm_lookfor').autocomplete('clear cache');
+    searchbox.autocomplete('clear cache');
   });
 }
 
-- 
GitLab