Created
September 28, 2016 08:07
-
-
Save mimikadze/707c133427e3f71484066149d8233184 to your computer and use it in GitHub Desktop.
searchkick livesearch fix for Eugeniy
This file contains hidden or 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
<%= form_tag root_path, :method => 'get' do %> | |
<div id="remote"> | |
<input class="typeahead" type="text" name="query" placeholder="Choose the book"> | |
</div> | |
<div class="col-md-1"> | |
<button type="submit" class="btn btn-default"> | |
<% end %> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
<script src="https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script> | |
<script> | |
var books = new Bloodhound({ | |
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'), | |
queryTokenizer: Bloodhound.tokenizers.whitespace, | |
remote: { | |
url: '/books/autocomplete?query=%QUERY', | |
wildcard: '%QUERY' | |
} | |
}); | |
$('#remote .typeahead').typeahead(null, { | |
source: books | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment