Replace typeahead with simpler autocomplete

This commit is contained in:
Paul Chavard 2018-08-22 15:06:19 +02:00
parent 2500cd516b
commit e1f1827320
21 changed files with 119 additions and 4818 deletions

View file

@ -57,32 +57,7 @@ function validatePath(path) {
}
function path_type_init() {
display = 'label';
var bloodhound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/admin/procedures/path_list?request=%QUERY',
wildcard: '%QUERY'
}
});
bloodhound.initialize();
$("#procedure_path").typeahead({
minLength: 1
}, {
display: display,
source: bloodhound,
templates: {
empty: 'Ce lien est disponible !',
suggestion: Handlebars.compile("<div class='path-mine-{{mine}}'>{{label}}</div>")
},
limit: 5
});
$('#procedure_path').bind('typeahead:select', function(ev, suggestion) {
$('#procedure_path').bind('autocomplete:select', function(ev, suggestion) {
togglePathMessage(true, suggestion['mine']);
});
}

View file

@ -148,8 +148,8 @@ function jsObject_to_array(qp_list) {
}
function add_event_search_address() {
$("#search-by-address input[type='address']").bind('typeahead:select', function (ev, seggestion) {
get_address_point(seggestion['label']);
$("#search-by-address input[type='address']").bind('autocomplete:select', function (ev, suggestion) {
get_address_point(suggestion['label']);
});
$("#search-by-address input[type='address']").keypress(function (e) {