Skip to content

Instantly share code, notes, and snippets.

@ananyo2012
Last active July 3, 2016 05:52
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 ananyo2012/c41b1c4a34313b3afa55b5141ea6506e to your computer and use it in GitHub Desktop.
Save ananyo2012/c41b1c4a34313b3afa55b5141ea6506e to your computer and use it in GitHub Desktop.
Typeahead example
$('#questions_searchform_input').typeahead({
items: 15,
minLength: 3,
source: function (query, process) {
return $.post('/questions_search/typeahead/' + query, {}, function (data) {
return process(data);
})
},
updater: function(item) {
var url;
if ($(item)[0] != undefined) url = $(item)[0].attributes['data-url'].value;
else url = '/questions_search/' + $('#questions_searchform_input').val();
window.location = url;
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment