Form: add address auto complete

This commit is contained in:
Simon Lehericey 2017-07-26 12:09:21 +02:00 committed by Mathieu Magnin
parent 1a485f173e
commit 1b42766836
5 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,27 @@
(function () {
var display = 'label';
var bloodhound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/ban/search?request=%QUERY',
wildcard: '%QUERY'
}
});
bloodhound.initialize();
var bindTypeahead = function() {
$("input[data-address='true']").typeahead({
minLength: 1
}, {
display: display,
source: bloodhound,
limit: 5
});
};
document.addEventListener('turbolinks:load', bindTypeahead);
})();