diff options
Diffstat (limited to 'public/javascripts/autocomplete.js')
-rw-r--r-- | public/javascripts/autocomplete.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/public/javascripts/autocomplete.js b/public/javascripts/autocomplete.js index 9cd6689..71fb17d 100644 --- a/public/javascripts/autocomplete.js +++ b/public/javascripts/autocomplete.js @@ -1,11 +1,10 @@ const EventEmitter = require('events') -const self = {} + +const self = new EventEmitter() self._items = [] self._selectedItemIndex = -1 -self.events = new EventEmitter() - self._nodes = { search: document.querySelector('#search'), input: document.querySelector('input[type="search"]'), @@ -68,7 +67,7 @@ self._handleItemClick = function (event) { const itemIndex = Array.prototype.indexOf .call(self._nodes.autocomplete.children, event.target) self._selectedItemIndex = itemIndex - self.events.emit('select', self.getSelectedItem()) + self.emit('select', self.getSelectedItem()) } self._handleKeydown = function (event) { |