Skip to content

Instantly share code, notes, and snippets.

@mitchellhislop
Created July 2, 2013 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellhislop/5911985 to your computer and use it in GitHub Desktop.
Save mitchellhislop/5911985 to your computer and use it in GitHub Desktop.
What a cool plugin. Fully awesome typeahead in ~25 lines.
$('#school .typeahead').typeahead({
name: 'schools',
prefetch: {
url: '/schoolsforstate/'+ state
filter: (data)->
$.each data, ()->
datumAdd = {
value: this.school_name
id: this.id
tokens:[
this.city
this.school_name
]
name: this.school_name
city: this.city
}
datum.push datumAdd
return datum
}
template: [
'<p class="school-name">{{name}}</p>',
'<p class="school-city">{{city}}</p>',
].join(''),
engine: Hogan
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment