Form: add address auto complete
This commit is contained in:
parent
1a485f173e
commit
1b42766836
5 changed files with 46 additions and 1 deletions
27
app/assets/javascripts/new_design/champs/address.js
Normal file
27
app/assets/javascripts/new_design/champs/address.js
Normal 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);
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue