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

always show all results #90

Closed achtan closed 9 years ago

achtan commented 9 years ago

Hi, I filter my results by my own, can i somehow force typeahed to always show all results?

sergeyt commented 9 years ago

@achtan try to invoke callback with all suggestions without filtering, also set data-min-length=0 to show drop-down on focus

achtan commented 9 years ago

i'm not sure if i know what u mean, but:

<input class="form-control typeahead search" name="search" type="text"
               placeholder="NBA teams"
               autocomplete="off" spellcheck="off"
               data-source="suggestions"
               data-selected="selected"
               data-min-length=0
               data-templates="suggestion"
               data-value-key="name"/>
Template.searchFilter.helpers({
  suggestions(query, sync, callback) {
    callback(Template.instance().suggestionsResults.get());
  }
});

i'm getting errors: on input focus: Uncaught TypeError: dataset.local is not a function on search: Uncaught TypeError: callback is not a function

with this helpers it works ok

Template.searchFilter.helpers({
  suggestions() {
    return Template.instance().suggestionsResults.get();
  }
});
sergeyt commented 9 years ago

@achtan suggestions function must take three arguments (query, sync, async) and you need to call sync(Template.instance().suggestionsResults.get()) to pass suggestion to typeahead plugin

sergeyt commented 9 years ago

@achtan btw the sample when suggestions function has three arguments should work

sergeyt commented 9 years ago

@achtan please try to reproduce issue with uncought TypeError in demo app and send the sample code with repro

achtan commented 9 years ago

ok with sync() it works, but there is still one issue: if i search for "f" i got zero results if i search for "fo" i got results for "f" search if i search for "foo" i got results for "fo" search and so on... there is a one-step-delay because my data Template.instance().suggestionsResults.get() comms from server and the suggestionshelpers is called before the new data arrive (my guess)

sergeyt commented 9 years ago

@achtan try to useasync as completion callback for Template.instance().suggestionsResults.get() request

achtan commented 9 years ago

but async is undefined in suggestions helpers function

sergeyt commented 9 years ago

@achtan async is last argument in your suggestions helper function

achtan commented 9 years ago

i know, but as i said, 3rd argument of helpers function is undefined

sergeyt commented 9 years ago

@achtan it seems you use v0.10.x version where async argument was second one

achtan commented 9 years ago

no i have: sergeyt:typeahead 0.11.1_1

sergeyt commented 9 years ago

@achtan I've added working example to demo app.