The typeahead.js plugin to make your inputs with autocomplete support packaged for meteor applications.
- Support fetching meteor collections as typeahead dataset
- Easy to bind auto-complete suggestions to input using
data-source
attribute - Allow using meteor template to visualize auto-complete suggestion
- Support most typeahead.js use cases:
- Asynchronous data sources
- Prefetched JSON data source
- Multiple datasets
Turns given HTML <input[type="text"]/>
into a typeahead.
element
- is HTML input element.source
- is optional custom data source function withfunction(query, sync, async)
signature wherequery
is text entered in the input andsync
,async
are callback functions expectingsuggestions
argument to show in dropdown.
Activates typeahead behavior for all elements matched by given CSS selector
. selector
parameter defaults to '.typeahead'.
typeahead.js dataset(s) is specified as data attribute if you don't specify custom data source function in Meteor.typeahead
call.
-
data-source
- name of function defined as helper for your meteor template with typeahead input. Optionally you could specifycollection.property
to automatically bind given meteor collection to your typeahead input -
data-sources
- name of template helper function that returns array of typeahead datasets.data-sets
is alias. Demo application has an example.
typeahead.js options are specified as data attributes in your input element. List of supported attributes:
-
data-highlight
– Iftrue
, when suggestions are rendered, pattern matches for the current query in text nodes will be wrapped in astrong
element withtt-highlight
class. Defaults tofalse
. -
data-hint
– Iffalse
, the typeahead will not show a hint. Defaults totrue
. -
data-min-length
– The minimum character length needed before suggestions start getting rendered. Defaults to1
. -
data-autoselect
– Iftrue
, the typeahead will select the first option when press enter key. Defaults tofalse
. -
data-value-key
- If the data-source returns objects, this can be used to set which attribute to use for the search text. If this is not specified, then it is assumed that each object will have an attribute namedvalue
that contains the search text.
Using data attributes you could specify handlers for corresponding typeahead opened
, closed
, selected
, autocompleted
events. Value of data attribute is name of template helper function to be used as event handler.
data-open
- specifies handler for fortypeahead:open
eventdata-close
- specifies handler for fortypeahead:close
eventdata-select
- specifies handler for fortypeahead:select
eventdata-autocomplete
- specifies handler for fortypeahead:autocomplete
event
See also typeahead docs for custom events.