Created
December 21, 2016 21:01
-
-
Save mlantz/7c382a5e70c8abf0aa8adef204d3faaf to your computer and use it in GitHub Desktop.
typeahead
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
$('.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