Socket
Socket
Sign inDemoInstall

knockout.typeahead

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knockout.typeahead

Simple knockout binding which wraps Twitter typeahead.js


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
5
Weekly downloads
 
Created
Source

#Knockout Typeahead Binding

Simple knockout binding which wraps Twitter typeahead.js

##Installation

npm install knockout.typeahead

##Usage

Include in your bundle with browserify or webpack. You will need to have a loader configured for less files in order to get styling from the included stylesheet, or you can bring your own.

<input data-bind="value: myValue, typeahead: autocompleteMyValue" />

with a view model that looks like this:

function ViewModel() {
	this.myValue = ko.observable();
	this.autocompleteMyValue = '/my/server/url?value=%QUERY';
}

If the remote endpoint you are querying is returning a complex object instead of an array of suggestions, you can pass a remoteFilter parameter to the binding, a function on your view model which returns the portion of the response object containing the array of suggestions.

If you are returning complex objects as suggestions, pass a templateName into the binding to use a custom template.

<input data-bind="value: myValue, typeahead: autocompleteMyValue, remoteFilter: pluckResults, templateName: 'my-suggestion-template'" />

Clone the repository then npm i && npm run start to build the example.

##Additional Binding Options

  • function mappingFunction: Function on your model which will map the suggestion data returned from your queries (e.g. so you can use computed observables and extenders in your template)
  • string displayKey: Property name on complex object suggestion data which will be used to populate the hint/value of the typeahead input.

Keywords

FAQs

Package last updated on 17 Jul 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc