Skip to content

Instantly share code, notes, and snippets.

@mokus80
Created February 10, 2015 10:57
Show Gist options
  • Save mokus80/1da4232337cd0a7ca06a to your computer and use it in GitHub Desktop.
Save mokus80/1da4232337cd0a7ca06a to your computer and use it in GitHub Desktop.
<body>
<form accept-charset="utf-8" action="<%= search_path %>">
<div class="where">
<input class="typeahead" id="where" type="text" placeholder="Ort, PLZ" id="user-search" spellcheck="false" />
<script src="//cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.10.4/typeahead.bundle.min.js"></script>
<script src="//cdn.jsdelivr.net/algoliasearch/latest/algoliasearch.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Replace the following values by your ApplicationID and ApiKey.
var algolia = new AlgoliaSearch('S28V4HJTQ8', '3aef8f24cf93555ef37e43432a6b41a8');
// replace YourIndexName by the name of the index you want to query.
var index = algolia.initIndex('subma_locations');
// typeahead.js initialization
$('#user-search').typeahead({ hint: false }, {
source: index.ttAdapter({ hitsPerPage: 5 }),
displayKey: 'location_name',
templates: {
suggestion: function(hit) {
// render the hit
return hit.location_name;
}
}
});
});
</script>
</div>
<button class="search" type="submit">
<%= t(:layout_finder_submit) %>
</button>
</form>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment