Created
July 2, 2013 18:49
-
-
Save mitchellhislop/5911985 to your computer and use it in GitHub Desktop.
What a cool plugin. Fully awesome typeahead in ~25 lines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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