Last active
August 29, 2015 13:58
-
-
Save redox/10434904 to your computer and use it in GitHub Desktop.
How to redefine ttAdapter()
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
var index = client.initIndex('YourIndexName'); | |
$('input#user_email').typeahead(null, { | |
// source is a function that takes the query and the typeahead.js callback function as parameters | |
source: function(query, cb) { | |
// perform the search | |
index.search(query, function(success, content) { | |
if (success) { | |
// at least one hit ? | |
if (content.hits.length > 0) { | |
firstHit = content.hits[0]; | |
} | |
// call the regular callback to inform typeahead about the results | |
cb(content.hits); | |
} | |
}, { hitsPerPage: 5 }); // force 5 hits only? | |
}, | |
name: 'users', | |
displayKey: 'email', | |
templates: { | |
suggestion: function(hit) { | |
return template.render(hit); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment