Backbone Typeahead
Integrates typeahead search into backbone collections.
View the online demo.
Examples
typeaheadAttributes: 'band''name''meta.members' : s = strim return null if slength is 0 tokens = for word in stoLowerCasesplit/[\s\-_]+/ i = 0 while i < wordlength tokenspushwordsubstri i++ tokens albums = band: 'A Flock of Seagulls'name: 'A Flock of Seagulls'meta: members: 'Mike Score' band: 'Rick Astley'name: 'Whenever You Need Somebody'meta: members: 'Rick Astley' band: 'Queen'name: 'A Day at the Races'meta: members: 'Freddie Mercury''Brian May' band: 'Queen'name: 'Tie Your Mother Down'meta: members: 'Freddie Mercury''Brian May' consolelog albumget'name' for album in albumstypeahead'you'# Outputs: # Whenever You Need Somebody # Tie Your Mother Down consolelog albumget'name' for album in albumstypeahead'ra'band: 'Queen'# Outputs: # A Day at the Races consolelog albumget'name' for album in albumstypeahead'fred'# Outputs: # A Day at the Races # Tie Your Mother Down # Custom tokenizer consolelog albumget'name' for album in albumstypeahead'ces'# Outputs: # A Day at the Races
Inspired by Twitter's typeahead.js.