0.0.26 upd autocomlitev2.js
This commit is contained in:
@@ -997,4 +997,15 @@ form.new_route{
|
||||
border-bottom-color: #26C9FF;
|
||||
outline: solid 1px #26C9FF;
|
||||
}
|
||||
/*autocomplete-wrapper END*/
|
||||
/*autocomplete-wrapper END*/
|
||||
|
||||
.input_list{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.input_list.show{
|
||||
display:block;
|
||||
height: 300px;
|
||||
width: 50%;
|
||||
overflow: scroll;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ function searchTown(el){
|
||||
// enctype: 'json',
|
||||
data: JSON.stringify(get_address_point),
|
||||
success: function(data){
|
||||
return data;
|
||||
return search(data)
|
||||
},
|
||||
error: function (data){
|
||||
console.log('++')
|
||||
@@ -27,27 +27,30 @@ function searchTown(el){
|
||||
|
||||
|
||||
|
||||
function search(e) {
|
||||
function search(data) {
|
||||
|
||||
let ac = document.querySelector("#id_from_country")
|
||||
let ac = document.querySelector("#id_from_address_point")
|
||||
|
||||
if (ac.value.length > 0) {
|
||||
|
||||
let results = searchTown(ac);
|
||||
let res_data = data.data
|
||||
|
||||
var divs = results.map(function(r, i) {
|
||||
var divs = res_data.map(function(r, i) {
|
||||
return '<div class="autocomplete-result" data-index="'+ i +'">'
|
||||
+ '<div><b>'+ r.iata +'</b> - '+ r.name +'</div>'
|
||||
+ '<div class="autocomplete-location">'+ r.city +', '+ r.country +'</div>'
|
||||
+ '<div><b>'+ r.iata_code +'</b> - '+ r.name +'</div>'
|
||||
+ '<div class="autocomplete-location">'+ r.city__name +', '+ r.city__country__name +'</div>'
|
||||
+ '</div>';
|
||||
});
|
||||
divs.attr('data-highlight', selectedIndex);
|
||||
document.querySelector(".input_list").innerHTML = divs
|
||||
|
||||
selectedIndex = -1;
|
||||
list.html(divs.join(''))
|
||||
.attr('data-highlight', selectedIndex);
|
||||
// .html(divs.join(''))
|
||||
// .attr('data-highlight', selectedIndex);
|
||||
|
||||
} else {
|
||||
numResults = 0;
|
||||
list.empty();
|
||||
divs.empty();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user