Dhaulagiri / ember-cli-twitter-typeahead

An ember cli typeahead component based on Twitter's jquery typeahead
MIT License
28 stars 14 forks source link

Cannot read property 'update' of undefined #18

Open pmackay opened 8 years ago

pmackay commented 8 years ago

I'm getting

Uncaught TypeError: Cannot read property 'update' of undefined

for

typeahead.dropdown.update(this.$().val());

Any thoughts what might be the cause?

Dhaulagiri commented 8 years ago

@pmackay can you share more about how you are using this?

robneville73 commented 8 years ago

I'm also getting this error.

It's pointing to this area of the code: focusIn: function focusIn() { var typeahead = undefined; if (!this.$().val()) { typeahead = this.$().data('ttTypeahead'); typeahead.dropdown.update(this.$().val()); <-- here } },

so it appears that dropdown is not always defined when this hits. If I start typing, it works. I really need it to work by displaying the list when the input is clicked on which it appears to be designed to do by the declaration of minLength: 0 in the typeahead bits.

This is a pretty simple example where I've dropped the component on a page and fed it a hard coded array from the controller as a test.

Other info: DEBUG: ------------------------------- ember.debug.js:5240DEBUG: Ember : 2.1.0 ember.debug.js:5240DEBUG: Ember Data : 2.1.0 ember.debug.js:5240DEBUG: jQuery : 1.11.3 ember.debug.js:5240DEBUG: -------------------------------

robneville73 commented 8 years ago

When I put a breakpoint in the code there, sure enough, typeahead does not contain a dropdown element.

I'm not sure I understand what you're trying to do here. The idea appears to be that I've focused on the text input and the input currently has no value so we want to update a jQuery data element named 'ttTypeahead' to a blank value? I couldn't find ttTypeahead referenced anywhere else in your project or in typeahead.js so not sure what we're trying to do here anyways but maybe there's another way to do it?

GiovanniL19 commented 7 years ago

Same issue here