From f4e988c314253464af3a2d7c4706d11801f75813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Thu, 21 Jun 2018 18:06:41 +0200 Subject: [PATCH] Prevent search form submit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- core/search/js/search.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/search/js/search.js b/core/search/js/search.js index 20d7f0f915..461c963c47 100644 --- a/core/search/js/search.js +++ b/core/search/js/search.js @@ -86,15 +86,19 @@ // Register input event document .getElementById('searchbox') - .addEventListener('input', _.debounce(this.search, 500), true); + .addEventListener('input', _.debounce(self.search, 500), true); document .querySelector('form.searchbox') - .addEventListener('submit', _.debounce(this.search, 500), true); + .addEventListener('submit', function(event) { + // Avoid form submit + event.preventDefault(); + _.debounce(self.search, 500); + }, true); // Register reset document .querySelector('form.searchbox') - .addEventListener('reset', _.debounce(this.reset, 500), true); + .addEventListener('reset', _.debounce(self.reset, 500), true); // Register esc key shortcut reset if focused document.addEventListener('keyup', function(event) {