Skip to content

Instantly share code, notes, and snippets.

@mlantz
Created December 21, 2016 21:01
Show Gist options
  • Save mlantz/7c382a5e70c8abf0aa8adef204d3faaf to your computer and use it in GitHub Desktop.
Save mlantz/7c382a5e70c8abf0aa8adef204d3faaf to your computer and use it in GitHub Desktop.
typeahead
$('.typeahead').typeahead({
hint: true,
highlight: true,
minLength: 3
}, {
async: true,
displayKey: 'name',
source: function (query, processSync, processAsync) {
processSync(actorMatcher(query, JSON.parse($('.typeahead').attr('data-suggestions'))));
return $.ajax({
url: "/actors/active",
type: 'GET',
data: { query: query },
dataType: 'json',
success: function (json) {
return processAsync(json);
}
});
}
}).on('typeahead:selected', function(event, data){
$('.actor-id').val(data.id);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment