Prevent search form submit

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-06-21 18:06:41 +02:00
parent 912a657d94
commit f4e988c314
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
1 changed files with 7 additions and 3 deletions

View File

@ -86,15 +86,19 @@
// Register input event // Register input event
document document
.getElementById('searchbox') .getElementById('searchbox')
.addEventListener('input', _.debounce(this.search, 500), true); .addEventListener('input', _.debounce(self.search, 500), true);
document document
.querySelector('form.searchbox') .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 // Register reset
document document
.querySelector('form.searchbox') .querySelector('form.searchbox')
.addEventListener('reset', _.debounce(this.reset, 500), true); .addEventListener('reset', _.debounce(self.reset, 500), true);
// Register esc key shortcut reset if focused // Register esc key shortcut reset if focused
document.addEventListener('keyup', function(event) { document.addEventListener('keyup', function(event) {