Last active
July 3, 2016 05:52
-
-
Save ananyo2012/c41b1c4a34313b3afa55b5141ea6506e to your computer and use it in GitHub Desktop.
Typeahead example
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
$('#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