Socket
Book a DemoInstallSign in
Socket

backbone.typeahead

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.typeahead

Backbone collection typeahead search with facet

1.1.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status

Backbone Typeahead

Integrates typeahead search into backbone collections.

View the online demo.

Examples

class Albums extends Backbone.TypeaheadCollection
  typeaheadAttributes: ['band', 'name', 'meta.members']
  tokenizeAttribute: (s) ->
    s = s.trim()
    return null if s.length is 0

    tokens = []

    for word in s.toLowerCase().split(/[\s\-_]+/)
      i = 0
      while i < word.length
        tokens.push(word.substr(i))
        i++

    tokens

albums = new 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'] }}
])

console.log album.get('name') for album in albums.typeahead('you')
# Outputs:
#  Whenever You Need Somebody
#  Tie Your Mother Down

console.log album.get('name') for album in albums.typeahead('ra', band: 'Queen')
# Outputs:
#  A Day at the Races

console.log album.get('name') for album in albums.typeahead('fred')
# Outputs:
#  A Day at the Races
#  Tie Your Mother Down

# Custom tokenizer
console.log album.get('name') for album in albums.typeahead('ces')
# Outputs:
#  A Day at the Races

Inspired by Twitter's typeahead.js.

Keywords

typeahead

FAQs

Package last updated on 30 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.