diff options
author | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 11:07:04 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2016-12-14 11:07:04 +0100 |
commit | 670976458b5375d27dc525f66b8faa3dc78e799b (patch) | |
tree | a90864d2d549efc6a5bce1b4cab99ffb60676f6d /public/javascripts/autocomplete.js | |
parent | cc60c30509e5b084f2b0c01ba22a6e43a446887f (diff) |
extend EventEmitter instaid of property
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) { |