Nil Pun
Nil Pun

Reputation: 17383

JQuery/Knockout Autocomplete script

I'm trying to find a resource in order to auto populate the location based on postcode provided.

e.g. When user types in 4 digits of post code, the auto complete kicks up and shows all the matched locations in format below. Postcode, Suburb, State e.g. 1234,abcSuburb,abcState.

I definately looks at jquery autocomplete at http://jqueryui.com/autocomplete/. However it appears that list only contains exact searched items. My requirement is is to get additional item_details based on item searched.

Any help will be appreciated.

Upvotes: 1

Views: 174

Answers (3)

Ravi Makwana
Ravi Makwana

Reputation: 2914

Use Ko.bindingHandlers for create custom function like so easy to implement and use

<input id="ainput" class="form-control" data-bind="jqAuto: actualValue, jqAutoOnChange: autoChange, jqAutoQuery: autoQuery, jqAutoSourceLabel: 'Description', jqAutoSourceInputValue: 'Name', jqAutoSourceValue: 'Id'" />

here Fiddle check out for working demo.

Upvotes: 0

Anders
Anders

Reputation: 17564

I've created a KO Combo, it coudl support this.

Live example 

http://jsfiddle.net/JD49k/6/

Repo https://github.com/AndersMalmgren/Knockout.Combobox

Upvotes: 0

dontmentionthebackup
dontmentionthebackup

Reputation: 2915

You should check out Twitter's Typeahead.js. They recently open sourced this and it's battle tested on twitter.com

Upvotes: 1

Related Questions