sergeyt / meteor-typeahead

Autocomplete package for meteor powered by twitter typeahead.js
https://atmospherejs.com/sergeyt/typeahead
MIT License
146 stars 82 forks source link

Are default suggestions possible? #83

Closed jdrorrer closed 9 years ago

jdrorrer commented 9 years ago

Are default suggestions possible with this package? Here is a link to what I mean: http://twitter.github.io/typeahead.js/examples/#default-suggestions

I'd like to be able to show the dropdown menu when the typeahead input is selected/focused on. I've been able to use the minLength option on the typeahead, and that properly adds the class tt-open to the tt-menu (typeahead dropdown menu) on focus, which is what I would expect. However, no results show up initially nor do they show up when I backspace everything, i.e. there are no characters in the typeahead input.

Is it possible to show a list of default suggestions like this? I should mention I am currently grabbing the results from the server using pub/sub with a limit. Thanks in advance!

sergeyt commented 9 years ago

@jdrorrer this should be easy to implement as in typeahead.js maybe without changing the package code. Now you try to use data-min-length = 0 attribute to specify minLength option for your typeahead input, data-source attribute should specify name of your template helper function with (query, sync, async) arguments. In that function try to write the similar code as in default-suggestions example.

jdrorrer commented 9 years ago

@sergeyt thanks for the response! I was able to get default suggestions working with a single data-source just by setting data-min-length=0. However, I have not been able to get it to work the same way with multiple data-sets for some reason. Perhaps that's not supported, but I'll have to dig into it a little more. Thanks again Sergey!

sergeyt commented 9 years ago

@jdrorrer FYI setting minLength: 0 property on every data-set could work as with single data set.