aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/search.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-01-30 14:04:20 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-01-30 14:04:20 +0100
commit25fbba2084a23fb62ab0e7fdf2dd47eadc28a967 (patch)
tree532293fef971164b21e3227955ff532668f850a1 /public/javascripts/search.js
parentacbdba98a7ab37e76c856cc751b78e2a974036b9 (diff)
Fix bugs in url update
- Document title doesn't update - Page crashes when going back to front page
Diffstat (limited to 'public/javascripts/search.js')
-rw-r--r--public/javascripts/search.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/public/javascripts/search.js b/public/javascripts/search.js
index a07d6dd..e6cf3a9 100644
--- a/public/javascripts/search.js
+++ b/public/javascripts/search.js
@@ -25,10 +25,17 @@ self.submit = function () {
}
self.updateDom = function (selectedItem) {
- self._nodes.input.value = selectedItem.value
- autocomplete.removeAllItems()
- document.body.classList.remove('no-input')
- document.body.classList.add('searched')
+ if (selectedItem == null) {
+ self._nodes.input.value = ''
+ autocomplete.removeAllItems()
+ document.body.classList.add('no-input')
+ document.body.classList.remove('searched')
+ } else {
+ self._nodes.input.value = selectedItem.value
+ autocomplete.removeAllItems()
+ document.body.classList.remove('no-input')
+ document.body.classList.add('searched')
+ }
}
self.focus = function () {